Ruby/Usage: Difference between revisions
(Created page with "== Usage == You have to use system ruby generally for several purposes, so you have to: # use application, which strictly requires ruby, like: [https://packages.altlinux.org/ru/sisyphus/srpms/foreman/specfiles foreman], [https://packages.altlinux.org/ru/sisyphus/srpms/gem-alexandria-book-collection-manager/specfiles gem-alexandria-book-collection-manager]; # use ruby for development only purposes on your local machine; Usage system ruby for production cases is UNSUPPOR...") |
|||
(15 intermediate revisions by the same user not shown) | |||
Line 5: | Line 5: | ||
# use ruby for development only purposes on your local machine; | # use ruby for development only purposes on your local machine; | ||
Usage system ruby for production | Usage system ruby for any other cases along with the specific production case is UNSUPPORTED. | ||
=== Installation === | |||
</tt># usermod [USER] -aG | |||
You have to install '''ruby''' for use just type in console as root: | |||
</tt># apt-get install ruby</tt> | |||
=== Post install === | |||
Our ruby uses '''rvm''' even for both '''build''' process and for '''usage'''. To use custom gems in userspace, to install an additional ruby gems or side modules, you have to add a user into ''ruby'' group: | |||
</tt># usermod [USER] -aG ruby</tt> | |||
or | or | ||
</tt>$ sudo bash -c "usermod \$SUDO_USER -aG rvm"</tt> | </tt>$ sudo bash -c "usermod \$SUDO_USER -aG ruby,rvm"</tt> | ||
And then '''''relogin''''' as the user. From time of relogin, additional gems will be installed for the user in the default '''$GEM_HOME''' folder ''/var/cache/ruby/gemie''. | |||
The group '''ruby''' is required to use ruby stdlib executables like ''gem'', ''bundle''. | |||
The group '''rvm''' is required to use ''rvm'' to install new or custom version of ruby, or link system's one. | |||
==== for root ==== | |||
Of course you still able to install custom gems as root user, so then treat all the calls to ruby executables as roots at all, like: | |||
</tt># gem server</tt> | |||
=== For development === | |||
Development package for ruby is called as the '''libruby-devel''', it contains all the prepequisites to ''build'' an other ruby with ''rvm'' or without, along with the development headers. Just install it as follows: | |||
</tt># apt-get install ruby-devel</tt> | |||
Then you have to use either embedded system rvm, or cumtomized user version. To install user version rvm just download it, by running: | |||
</tt>$ \curl -sSL https://get.rvm.io | bash -s stable</tt> | |||
Then relogin and mount systems' or install required ruby as follows: | |||
</tt>$ rvm install ruby-3.3.0</tt> | |||
==== Cloning a custom project ==== | |||
With rvm and ruby you are able to both developing a custom project and even running it in production. For example to run redmine project in production you have to just execute the steps: | |||
</tt>$ git clone https://github.com/redmine/redmine.git</tt> | |||
</tt>$ cd redmine</tt> | |||
</tt>$ bundle</tt> | |||
</tt>$ yarn install</tt> | |||
Then edit config/database.yml file properly according your requirements, and set the necessary database user/role for corresponding DB engine, run creation, migration procedures for the database, and seeding if any. | |||
</tt>$ RAILS_ENV=production rake db:create db:migrate db:seed</tt> | |||
And run application. | |||
</tt>$ RAILS_ENV=production rails s</tt> |
Latest revision as of 04:44, 6 August 2024
Usage
You have to use system ruby generally for several purposes, so you have to:
- use application, which strictly requires ruby, like: foreman, gem-alexandria-book-collection-manager;
- use ruby for development only purposes on your local machine;
Usage system ruby for any other cases along with the specific production case is UNSUPPORTED.
Installation
You have to install ruby for use just type in console as root:
# apt-get install ruby
Post install
Our ruby uses rvm even for both build process and for usage. To use custom gems in userspace, to install an additional ruby gems or side modules, you have to add a user into ruby group:
# usermod [USER] -aG ruby
or
$ sudo bash -c "usermod \$SUDO_USER -aG ruby,rvm"
And then relogin as the user. From time of relogin, additional gems will be installed for the user in the default $GEM_HOME folder /var/cache/ruby/gemie.
The group ruby is required to use ruby stdlib executables like gem, bundle.
The group rvm is required to use rvm to install new or custom version of ruby, or link system's one.
for root
Of course you still able to install custom gems as root user, so then treat all the calls to ruby executables as roots at all, like:
# gem server
For development
Development package for ruby is called as the libruby-devel, it contains all the prepequisites to build an other ruby with rvm or without, along with the development headers. Just install it as follows:
# apt-get install ruby-devel
Then you have to use either embedded system rvm, or cumtomized user version. To install user version rvm just download it, by running:
$ \curl -sSL https://get.rvm.io | bash -s stable
Then relogin and mount systems' or install required ruby as follows:
$ rvm install ruby-3.3.0
Cloning a custom project
With rvm and ruby you are able to both developing a custom project and even running it in production. For example to run redmine project in production you have to just execute the steps:
$ git clone https://github.com/redmine/redmine.git $ cd redmine $ bundle $ yarn install
Then edit config/database.yml file properly according your requirements, and set the necessary database user/role for corresponding DB engine, run creation, migration procedures for the database, and seeding if any.
$ RAILS_ENV=production rake db:create db:migrate db:seed
And run application.
$ RAILS_ENV=production rails s