When I input:
ruby -v
I get:
ruby 1.8.7
but with:
rvm list
I get:
=* ruby-2.2.1 [ x86_64 ]
# => - current
# =* - current && default
# * - default
What is causing this mismatch? How do I correct it so I always use 2.2.1?
I would guess there is something wrong with your $PATH and you are referencing the system ruby maybe? I would recommend double checking the install directions.
You could also try running again:
echo "source $HOME/.rvm/scripts/rvm" >> ~/.bash_profile
Finally, once you get that working, I also find using .ruby-version and .ruby-gemset files in repos/folders very helpful. See "Typical RVM Project Workflow" for more info.
Related
Ok so first off I've seen almost all if not all the posts on this here and nothing has worked. Furthermore I don't know how but I have got this to work on a different environment which is basically a clone of my current set up. I just can't pin point what's different between the two.
Issue:
I have ruby-2.5.0 set as my default but on each new terminal session I get reverted back to ruby-2.3.3
So here's my RVM list
=> ruby-2.3.3 [ x86_64 ]
* ruby-2.5.0 [ x86_64 ]
2.5.0 set as my default, in my other env I simply ran
rvm use 2.5.0 --default
and I'd get 2.5.0 whenever I started a new session. That's not working here.
HERE is a gist with my bashrc, bash_profile, and zshrc files.
Got it working running these 2 commands
$ rvm alias create default 2.5.0
$ rvm default 2.5.0
This issue seems to relate to Default Ruby not loading with RVM, but the answer do not help me.
On my Ubuntu 14 LTS, I've got 2 rubies installed in rvm and set 2.2-head as default using rvm use 2.2-head --default. After reopening terminal (login shell is configured) 2.2 does not get set as current
$ rvm list
rvm rubies
=> ruby-2.1.5 [ x86_64 ]
* ruby-2.2-head [ x86_64 ]
# => - current
# =* - current && default
# * - default
I couldn't find any .ruby-version or .rvmrc in current ($HOME) folder (or its parents).
Meanwhile I tried removing system ruby (1.9.3), but this has no effect, too.
What did I miss?
Problem could be solved by rebooting system, although I don't know why this works
Have you followed the instructions on https://rvm.io/rubies/default?
RVM doesn't use the default Ruby version on both my Mac and Ubuntu server.
This is what I get when I do rvm list on my Mac:
rvm rubies
* ruby-2.1.2 [ x86_64 ]
# => - current
# =* - current && default
# * - default
And what I get on Ubuntu:
rvm rubies
* ruby-2.1.2 [ i686 ]
# => - current
# =* - current && default
# * - default
They are already the default and only version available, but I have to manually type rvm use 2.1.2 each time when I need to do some Ruby stuff. I guess I could put that command into .profile or the like, but it feels hackish since I'm expecting RVM to use the default version.
Does anyone have a better solution?
I resolved the problem.
I tried rvm use ruby-2.1.2 --default multiple times and it didn't work. There's two things I did:
I moved this line:
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*
in ~/.bash_profile to the last line. See "How to use "RVM --default" on MacOSX".
Somehow some application decided to add itself to this file and making it the first in the path.
Run rvm get head.
This solved the problem for me on my Mac.
We need a certain gem application run on a cron schedule, so we have a dedicated user set up to run this gem.
We are currently using ruby 1.9.2
[jobrunner#test-load] rvm list
rvm rubies
ruby-1.8.7-p299 [ x86_64 ]
ruby-1.9.2-p180 [ x86_64 ]
=* ruby-1.9.2-p290 [ x86_64 ]
ruby-1.9.3-p125 [ x86_64 ]
ruby-1.9.3-p374 [ x86_64 ]
ruby-1.9.3-p392 [ x86_64 ]
ruby-1.9.3-p448 [ x86_64 ]
ruby-2.0.0-p247 [ x86_64 ]
# => - current
# =* - current && default
# * - default
Unfortunately I need this user to run on ruby 1.9.3. Changing the default ruby version is not an option because rvm is installed system wide (/usr/local/rvm/bin/rvm) and other users on the system rely on 1.9.2.
If I were in an interactive session, it would be as simple as
rvm use 1.9.3
However, it appears I can't use rvm use in a non-interactive session (i.e. in the crontab). (I tried it by sticking that in my bashrc file and telling cron to look at my bashrc file. I ended up forkbombing myself..)
How do I get my crontab using a specific version of ruby via rvm?
From tty switch ruby version:
rvm use 1.9.3
You should set up cron with rvm:
rvm cron setup
then your crontab would look like this:
PATH="/usr/local/rvm/gems/ruby-1.9.3-p194/bin:/usr/local/rvm/gems/ruby-1.9.3-p194#global/bin:/usr/local/rvm/rubies/ruby-1.9.3-p194/bin:/usr/local/rvm/bin:/usr/local/rvm/gems/ruby-1.9.3-p194/bin:/usr/local/rvm/gems/ruby-1.9.3-p194#global/bin:/usr/local/rvm/rubies/ruby-1.9.3-p194/bin:/usr/local/rvm/bin:/usr/lib64/qt-3.3/bin:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/usr/local/rvm/gems/ruby-1.9.3-p194#global/"
rvm_env_string='ruby-1.9.3-p194'
rvm_path='/usr/local/rvm'
rvm_ruby_string='ruby-1.9.3-p194'
RUBY_VERSION='ruby-1.9.3-p194'
GEM_HOME='/usr/local/rvm/gems/ruby-1.9.3-p194'
GEM_PATH='/usr/local/rvm/gems/ruby-1.9.3-p194:/usr/local/rvm/gems/ruby-1.9.3-p194#global'
MY_RUBY_HOME='/usr/local/rvm/rubies/ruby-1.9.3-p194'
IRBRC='/usr/local/rvm/rubies/ruby-1.9.3-p194/.irbrc'
Cron would use 1.9.3 ruby with the above
EDIT
Just noticed my text was not well formatted on SO, so I have reformatted it
You can source the rvm confined ruby from your script like this:
#!/usr/bin/env bash
# load rvm ruby
source /usr/local/rvm/environments/ruby-1.9.3-p448#projectX
# ..... rake, ruby, whatever you need your script to do
When I try to run any ruby code, I get a pop up that Says "Launching differences2.rb' has encountered a problem. Unable to find a Ruby executable.
When I run 'gem environment' from inside Aptana I get this:
gem environment
RubyGems Environment:
- RUBYGEMS VERSION: 1.8.6
- RUBY VERSION: 1.9.2 (2011-07-09 patchlevel 290) [x86_64-linux]
- INSTALLATION DIRECTORY: /home/adamar/.rvm/gems/ruby-1.9.2-p290
- RUBY EXECUTABLE: /home/adamar/.rvm/rubies/ruby-1.9.2-p290/bin/ruby
- EXECUTABLE DIRECTORY: /home/adamar/.rvm/gems/ruby-1.9.2-p290/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-linux
- GEM PATHS:
- /home/adamar/.rvm/gems/ruby-1.9.2-p290
- /home/adamar/.rvm/gems/ruby-1.9.2-p290#global
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- http://rubygems.org/
When I run 'ruby -v' from inside Aptana I get this:
ruby -v
ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-linux]
When I run 'rvm use 1.9.2' from inside Aptana I get :
rvm use 1.9.2
Using /home/adamar/.rvm/gems/ruby-1.9.2-p290
I restarted and tried again after each of those commands, I also tried this:
rvm use 1.9.2 --default
Can anyone make a suggestion as to what I can do?
It's not clear from your question which version of Aptana you're using. If you're using Aptana Studio 3.x, then it should pick up your environment setup in .bashrc and your typical shell setup. We basically just search PATH for the location of the ruby executable. It'd be useful to see the output of "echo $PATH" inside the Terminal view in the IDE and outside the IDE to see if they differ. However it seems like it's already finding it when you run the "ruby -v" command in the shell, so I'm not really clear on what the issue might be.
You can try turning on debug level logging inside Preferences > Aptana Studio > Troubleshooting. You can up the log level to "All", and/or check "Debug specific components" and check the com.aptana.core/debug and com.aptana.core/debug/shell entries. That should hopefully spit out low level details on what process get run under the hood and the command lien args, executables and environment used. You can view the log by going to Help > Aptana > View Log File. We typically ask for the contents of this log when users file bugs at http://jira.appcelerator.org/secure/CreateIssue!default.jspa
I had the same problem and "solved" it by removing all references to Cygwin from my PATH. It must not be parsing it correctly when Cygwin goes in and changes your path.
I had the same problem working on Ubuntu with rvm, so I created a symbolic link, like sudo ln -s ~/progs/Aptana\ Studio\ 3/AptanaStudio3 /usr/local/bin/aptana and from a terminal execute aptana &
Try going to the folder where Aptana is installed and edit the file "studio3".
Add this in the begging
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session as a function
This will force it to load your rvm path when opening Aptana. You can then run open it by using ./studio3
I noticed that when running
Aptana terminal loads the .aptanarc instead of .bashrc on start up. You can adjust the path configurations for rbenv like this
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.aptanarc
echo 'eval "$(rbenv init -)"' >> ~/.aptanarc
I found this on another site and it helped my Apatana find the ruby executable. I would cite the author, but there is no name.