Have next situation:
Using jenkins
Installed rvm with different ruby versions(2+)
Installed rvm plugin
Enabled option "Run the build in a RVM-managed environment" in "Build Environment" with ruby version ruby-2.3.0#global
Now about problem. After each starting of jenkins job I can see next output:
Capturing environment variables produced by 'rvm use ruby-2.3.0#global'
$ bash -c export
[workspace] $ bash -c " source /usr/local/rvm/scripts/rvm && rvm use --install --create ruby-2.3.0#global && export > rvm.env"
Using /usr/local/rvm/gems/ruby-2.3.0 with gemset global
...
And seems everything should works ok.
But in fact jenkins use ruby-2.2.0 because below in log I found this:
+++ __path_to_ruby=/usr/local/rvm/rubies/ruby-2.2.0/bin/ruby
+++ [[ -z /usr/local/rvm/rubies/ruby-2.2.0/bin/ruby ]]
+++ [[ /usr/local/rvm/rubies/ruby-2.2.0/bin/ruby != \/\u\s\r\/\l\o\c\a\l\/\r\v\m* ]]
+++ [[ /usr/local/rvm/rubies/ruby-2.2.0/bin/ruby == \/\u\s\r\/\l\o\c\a\l\/\r\v\m\/\b\i\n\/\r\u\b\y ]]
+++ [[ /usr/local/rvm/rubies/ruby-2.2.0/bin/ruby == \/\u\s\r\/\l\o\c\a\l\/\r\v\m* ]]
+++ [[ -z /usr/local/rvm/gems/ruby-2.2.0 ]]
+++ [[ -z /usr/local/rvm/gems/ruby-2.2.0:/usr/local/rvm/gems/ruby-2.2.0#global ]]
...
And next problem which stems from here:
Gem::InstallError: activesupport requires Ruby version >= 2.2.2.
Also if I type ruby -v command in "Execute shell" area - then in log I see this
+ ruby -v
ruby 2.2.0p0 (2014-12-25 revision 49005) [x86_64-linux]
I also tried to start command rvm use ruby-2.3.0 directly in "Execute shell".
Also I added this into /var/lib/jenkis/.bashrc:
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"
And tried to change $HOME/.rvm to /usr/local/rvm
But everytime result the same. Jenkins does not use ruby-2.3.0
Please help me figure out what did I miss?
I ran into this problem too. It turned out that there is an issue if you install rvm as root. We had to fully uninstall rvm and reinstall as the jenkins user, after which the plugin correctly loaded rubies.
You can detect this problem by listing the contents of the directory pointed by Jenkins's $HOME variable. If there is no .rvm directory then you may need to reinstall.
Related
in mac osx el-capitan .bash_history has stopped working when i close the window or session after i installed ruby (using either rvm or rbebnv) the last lines recorded by bash_history are;
rvm get stable --autolibs=enable
OR
rbenv install 2.3.0
If i comment out below lines in .bash_profile and .profile, .bash_history resumes...
[[ -s "$HOME/.profile" ]] && source "$HOME/.profile" # Load the default .profile
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *$
OR
if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi
I want to work on rails with a bash history.
Please let me know if i can get bash history working
I encountered the same problem, it was resolved here.
Simply update your RVM using rvm get head.
You could also create a .bash_logout file with the following:
shell_session_update
Sourced from GitHub comment
I cloned a Rails app developed by another person within my company from Github.
When I cd into the app's directory I get this message in the terminal:
You are using '.rvmrc', it requires trusting, it is slower and it is not compatible with other ruby managers,
you can switch to '.ruby-version' using 'rvm rvmrc to [.]ruby-version'
or ignore this warning with 'rvm rvmrc warning ignore /Users/george/evil-genius/Loopadoop/.rvmrc',
'.rvmrc' will continue to be the default project file in RVM 1 and RVM 2,
to ignore the warning for all files run 'rvm rvmrc warning ignore all.rvmrcs'.
Then when I try to run any rails command e.g. rails server I get this error:
/Users/george/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/rubygems/dependency.rb:247:in `to_specs': Could not find railties (>= 0) amongst [rvm-1.11.3.8] (Gem::LoadError)
from /Users/george/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/rubygems/dependency.rb:256:in `to_spec'
from /Users/george/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/rubygems.rb:1231:in `gem'
from /Users/george/.rvm/rubies/ruby-1.9.3-p448/bin/rails:22:in `<main>'
If I run rvm rvmrc to .ruby-version, I no longer get the "you are using '.rvmrc'..." warning, but I still get the same error message about railties when trying to run rails commands.
rvm list shows these versions of Ruby installed:
rvm rubies
* ruby-1.9.3-p385 [ x86_64 ]
=> ruby-1.9.3-p448 [ x86_64 ]
ruby-2.0.0-p195 [ x86_64 ]
ruby-2.0.0-p247 [ x86_64 ]
# => - current
# =* - current && default
# * - default
And my rvm version is 1.22.18.
What's happening? I don't understand rvm or .rvmrc files at all, and all other Rails stuff in other apps on my machine work perfectly fine. How can I get this rails app to work?
FWIW, here's what the .rvmrc file looks like when I first clone the repo from GH. (Comments removed for brevity):
#!/usr/bin/env zsh
environment_id="ruby-1.9.3-p448#loopAdoop"
if [[ -d "${rvm_path:-$HOME/.rvm}/environments"
&& -s "${rvm_path:-$HOME/.rvm}/environments/$environment_id" ]]
then
\. "${rvm_path:-$HOME/.rvm}/environments/$environment_id"
for __hook in "${rvm_path:-$HOME/.rvm}/hooks/after_use"*
do
if [[ -f "${__hook}" && -x "${__hook}" && -s "${__hook}" ]]
then \. "${__hook}" || true
fi
done
unset __hook
if (( ${rvm_use_flag:=1} >= 2 )) # display only when forced
then
if [[ $- == *i* ]] # check for interactive shells
then printf "%b" "Using: \E[32m$GEM_HOME\E[0m
" # show the user the ruby and gemset they are using in green
else printf "%b" "Using: $GEM_HOME
" # don't use colors in non-interactive shells
fi
fi
else
rvm --create "$environment_id" || {
echo "Failed to create RVM environment '${environment_id}'."
return 1
}
fi
And after I run rvm rvmrc to .ruby-version, the .rvmrc file is deleted, and two new files are generated: .ruby-gemset, which just contains the name of my app, and .ruby-version, which just contains the text "ruby-1.9.3-p448"
you need to run:
gem install bundler &&
bundle install
it will install the gems needed for this project
you can make it automated on cd with:
echo rvm_autoinstall_bundler_flag=1 >> ~/.rvmrc
I feel that this is a symptom of a nonfunctioning rvm install but I don't know what's going wrong; I used the command on https://rvm.io/m (\curl -L https://get.rvm.io | bash -s stable --ruby)
Note: I can install gems successfully
myprompt: which gem
gem () {
typeset result
(
typeset rvmrc
rvm_rvmrc_files=("/etc/rvmrc" "$HOME/.rvmrc")
if [[ -n "${rvm_prefix:-}" ]] && ! [[ "$HOME/.rvmrc" -ef "${rvm_prefix}/.rvmrc" ]]
then
rvm_rvmrc_files+=("${rvm_prefix}/.rvmrc")
fi
for rvmrc in "${rvm_rvmrc_files[#]}"
do
[[ -s "${rvmrc}" ]] && source "${rvmrc}" || true
done
unset rvm_rvmrc_files
command gem "$#"
) || result=$?
hash -r
return ${result:-0}
}
myprompt:
I had the same "problem", using zsh on Mac OS X. After a bit of searching I found it's actually the standard behaviour. For a more thorough answer check out this SO question Zsh `which rvm` or `which gem` returns the function contents instead of the path
I wouldn't worry about that output; gem and rvm are supposed to be functions.
But I'm a little puzzled as to why which shows the functions. What OS/distro are you running? And what shell? It looks like your which is a shell built-in command; in bash it isn't, so perhaps you're using csh or zsh.
When I enter my rails dir on server RVM switch to
/home/capistrano/.rvm/gems/ruby-1.9.2-p290#global/bin/bundle
although it should use ruby-1.9.2-p290#mygemset/bin/bundle as it works on my local machine. When I type rvm use 1.9.2#mygemset it works. Nginx server is also looking for gems in the #global gemset
my .rvmrc file:
environment_id="ruby-1.9.2-p290#mygemset"
if [[ -d "${rvm_path:-$HOME/.rvm}/environments" \
&& -s "${rvm_path:-$HOME/.rvm}/environments/$environment_id" ]]
then
\. "${rvm_path:-$HOME/.rvm}/environments/$environment_id"
if [[ -s "${rvm_path:-$HOME/.rvm}/hooks/after_use" ]]
then
. "${rvm_path:-$HOME/.rvm}/hooks/after_use"
fi
else
# If the environment file has not yet been created, use the RVM CLI to select.
if ! rvm --create use "$environment_id"
then
echo "Failed to create RVM environment '${environment_id}'."
return 1
fi
fi
I'm not sure if I understood you but you could place an .rvmc file in your rails folder and put something like this in it.
rvm use ruby-1.9.2#mygemset
Whenever you cd into that directory rvm will use settings from the .rvmc file.
RVM is going through rapid develpment so the syntax and functionality of commands sometimes vary. Anyway, I solved it with upgrading to stable RVM:
rvm get stable
which is now rvm 1.14.1 (stable). Afterwards commands like rvm 1.9.3-p194#mygemset --create
works perfectly.
Another thing I was missing is the new syntax for executing commands:
rvm #mygemset do bundle install
This will install all gems for given gemset and ruby specified in .rvmrc file
I have installed ruby via rvm on Mint 11 no problem. Installed gems, ditto. Installed rails via gem install rails, and when I type rails -v it returns the correct version. Until I close that terminal and reopen a terminal. When I do that and type rails -v I get the message
The program 'rails' is currently not installed. You can install it by typing: sudo apt-get install rails
If I then type
rvm use 1.9.2-p180 --default
and then type rails -v I again get the correct version...until I close the terminal.
I should add that I have added a path statement to my .bashrc pointing to the 1.9.2-p180 directory in my .rvm directory.
Typing ruby -v always returns the correct version.
Create .bashrc file and add .rvm command
$ sudo touch ~/.bashrc
$ sudo gedit ~/.bashrc
(Add line to .bashrc file)
if [[ -s "$HOME/.rvm/scripts/rvm" ]] ; then source "$HOME/.rvm/scripts/rvm" ; fi
Logout and Login OR just update user profile from .bashrc with following command
$ . ~/.bashrc
Try adding this command to your .profile and reopening your shell:
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # This loads RVM into a shell session.
Use project rvmrc files. You can see how to set this up here http://beginrescueend.com/rvm/best-practices/
That way you keep all your gems seperate for each project and it's dead simple to set up
Try which rails. Maybe there is a link to a stub that gives you the note.
If that is the case calling the full path might help, e.g. /usr/local/bin/rails