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
Related
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.
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 am getting this error below
/usr/lib64/ruby/site_ruby/1.8/rubygems.rb:926:in `report_activate_error': Could not find RubyGem rails (>= 0) (Gem::LoadError)
from /usr/lib64/ruby/site_ruby/1.8/rubygems.rb:244:in `activate_dep'
from /usr/lib64/ruby/site_ruby/1.8/rubygems.rb:236:in `activate'
from /usr/lib64/ruby/site_ruby/1.8/rubygems.rb:1307:in `gem'
from /usr/bin/rails:18
i started with a ruby 1.8.7 & rails 2.3.11
then i installed rvm
then installed ruby 2.0.0 & gem install rails 3.2.13
then started getting this error above.
any help will be appreciated, thanks.
i think it's a path issue of some sort but can't figure out, don't know much about unix stuff. i don't have root privs by the way.
this is my .bashrc if helps
# .bashrc
# User specific aliases and functions
alias mv='mv -i'
alias rm='rm -i'
alias cp='cp -i'
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
PATH=$PATH:$HOME/.rvm/bin # Add RVM to PATH for scripting
export HPATH=$HOME
export GEM_HOME=$HPATH/ruby/gems
export GEM_PATH=$GEM_HOME:/usr/lib64/ruby/gems/1.8
export GEM_CACHE=$GEM_HOME/cache
export PATH=$PATH:$HPATH/ruby/gems/bin
export PATH=$PATH:$HPATH/ruby/gems
this is .bash_profile
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
PATH=$PATH:$HOME/bin
export PATH
unset USERNAME
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM$
rvm use 2.0.0
will switch to ruby 2.0.0
You can then install rails and create a gemset named rails-3.2.13
rvm use 2.0.0#rails-3.2.13 --create
then
gem install rails -v 3.2.13
you can also pass the --default switch to make 2.0.0 the default ruby
you can see a list if all installed ruby versions and which one is current and or default using
rvm list
this produces output like this
rvm rubies
ruby-1.9.3-p385 [ x86_64 ]
=* ruby-1.9.3-p392 [ x86_64 ]
ruby-2.0.0-p0 [ x86_64 ]
# => - current
# =* - current && default
# * - default
UPDATE
Also, This seems like a PATH issue since your last comment. Im not sure about your bash_profile but the PATH may be wrong for rvm. Just use
export PATH="/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:$PATH"
# Load RVM into a shell session *as a function*
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"
in your bash_profile
and in your `.bashrc' try this
PATH=$PATH:$HOME/.rvm/bin # Add RVM to PATH for scripting
I set up rvm (and .rvmrc file) not properly, therefore whenever I go the directory of my RoR project and type rails s or any other rails command, I'll get the error of
The program 'rails' can be found in the following packages:
* rails
* ruby-railties-3.2
Try: sudo apt-get install <selected package>
and I have to type rvm use 1.9.3-p392 to fix it.
.rvmrc file contains
environment_id="ruby-1.9.3-p392#project1"
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
else
# If the environment file has not yet been created, use the RVM CLI to select.
rvm --create "$environment_id" || {
echo "Failed to create RVM environment '${environment_id}'."
return 1
}
fi
Try
rvm use ruby-1.9.3-p391 --default
.rvmrc in the newest version of RVM is deprecated. It should work but try new syntax:
put to .ruby-version file just:
1.9.3-p392
Additionaly you can define .ruby-gemset with
yourgemsetname
Post your rvmrc file in order to get some help.
If you want to check a look at other's project rvmrc file you can take a look at octopress here. Also you can take a look at rvmrc docs if you haven't already looked.
The message you've got is from the autocomplete ubuntu/debian projects, meaning that it can't found the rails command, so it suggests the packages you can install to get it.
Probably you havent loaded the rvm environment. You can load it via:
source $HOME/.rvm/scripts/rvm
and then check if it works.
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