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.
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
Working on a brand new ArchLinux install with rails (4) installed using gem. Logged in as usr instead of root, per ArchWiki recommendation for using gem.
Install is successful, but puts out this warning:
WARNING: You don't have /home/[usr]/.gem/ruby/2.0.0/bin in your PATH,
gem executables will not run.
After much googling, I edited both .bashrc and .bash_profile hoping to rectify the issue.
#
# ~/.bashrc
#
# If not running interactively, don't do anything
[[ $- != *i* ]] && return
alias ls='ls --color=auto'
PS1='[\u#\h \W]\$ '
export GEM_HOME=~/.gem/ruby/2.0.0
export PATH=$PATH:/home/[name]/.gem/ruby/2.0.0/bin
$(ruby -rubygems -e "puts Gem.user_dir")/bin
#
# ~/.bash_profile
#
[[ -f ~/.bashrc ]] && . ~/.bashrc
export GEM_HOME=~/.gem/ruby/2.0.0
export PATH=$PATH:/home/[usr]/.gem/ruby/2.0.0/bin
$(ruby -rubygems -e "puts Gem.user_dir")/bin
I know it's redundant, but I've seen recommendations for both files, and after one didn't work I was hoping the other would.
Either way, even after uninstalling and reinstalling rails, the warning still pops up and rails is still not a usable command. I'm not really sure where to go from here, since it seems those lines tend to fix it for others.
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.
I just recently switched over to using zsh with oh-my-zsh and I am having issues using the rails command line tool. Here are the steps that I ran through, and the error that I am receiving.
I ran the curl command that the github page provides:
curl -L https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh | sh
Then I went to run rails s, this is the following error message that I receive:
.rvm/rubies/ruby-1.9.3-p0/lib/ruby/site_ruby/1.9.1/rubygems/dependency.rb:247:in `to_specs': Could not find railties (>= 0) amongst [bigdecimal-1.1.0, io-console-0.3, json-1.5.4, minitest-2.5.1, rake-0.9.2.2, rdoc-3.9.4] (Gem::LoadError)
This looks like I am having a gem error so I reinstalled rvm, rails and bundler with nothing solving the issue. However if I switch my terminal back over to bash then I dont have any issues and rails works perfectly fine. Has anyone else run into a similar issue? I want to use zsh because it seems like it has better features but if I can't use rails then I have to dump it to the curb.
These are the lines at the end of my .zshrc file:
export PATH=/Users/thomascioppettini/.rvm/gems/ruby-1.9.3p0/bin:/Users/thomascioppettini/.rvm/gems/ruby-1.9.3-p0#global/bin:/Users/thomascioppettini/.rvm/rubies/ruby-1.9.3-p0/bin:/Users/thomascioppettini/.rvm/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/git/bin:/usr/X11/bin
PATH=$PATH:$HOME/.rvm/bin # Add RVM to PATH for scripting
What I have done to work bundle zsh and rvm, that is couple of body movies:
1) add to .zshrc at first line to correct find bin direcrory (your CO):
PATH=$PATH:$HOME/.rvm/bin # Add RVM to PATH for scripting
2) add next line after previous one:
[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm"
3) and at the end change PATH:
export PATH=$PATH:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
For me it is work fine (now it correct define $PATH with all rvm gemsets)
did you put the
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # This loads RVM into a shell session.
into your .zshrc?
I assume the rvm-installer installs it only into .bashrc
Ok I got it to work by deleting the path that was set in the zshrc and copying the rvm lines from my bash_profile in order to get the right configuration from rvm. If you run the following command in your terminal it should work:
cat ~/.bash_profile >> ~/.zshrc
If you are using rbenv then copy this line from bash.rc which you can access by sudo gedit ~/.bashrc
export PATH="$HOME/.rbenv/bin:$PATH"
eval "$(rbenv init -)"
export PATH="$HOME/.rbenv/bin:$PATH"enter code here
eval "$(rbenv init -)"
then paste it to zshrc, which can be accessed by sudo gedit ~/.zshrc