I have been using Ruby on Rails with postgresql and something suggested that I should install RVM which I did (I think it was to utilise Phonegap). Since I put RVM in place I have been unable to execute bundle install which in turn means that I can no longer run other rails commands.
Lots of reading hasn't really given me an answer but I have lots of ideas. Maybe someone can help focus those ideas into a solution?
When I run bundle install there are 3 gems that seem to be causing the problem, but I think they are interlinked. They are byebug 8.2.2 and pg 0.18.4 and binding_of caller 0.7.2
The contents of byebug-8.2.2/gem_make_out are as follows:
/home/damo/.rvm/rubies/jruby-9.0.5.0/bin/jruby -r ./siteconf20160927-16151-j7mhkf.rb extconf.rb
NotImplementedError: C extensions are not supported
<top> at /home/damo/.rvm/rubies/jruby-9.0.5.0/lib/ruby/stdlib/mkmf.rb:1
require at org/jruby/RubyKernel.java:937
(root) at /home/damo/.rvm/rubies/jruby-9.0.5.0/lib/ruby/stdlib/rubygems/core_ext/kernel_require.rb:1
<top> at extconf.rb:6
extconf failed, exit code 1
When I look at byebug issues it simply says that byebug doesn't support jruby.
I did not have any issues before I installed RVM and I'm sure I read that byebug was hardwired into Rails 4. I wanted to tell you my Rails version but rails -v gives me a response of
Could not find proper version of railties (4.2.5) in any of the sources
Run `bundle install` to install missing gems.
Which seems to be my Catch 22!
This kinda sounds like you're not using RVM in a login shell. In Bash you can run bash -l, then source ~/.bashrc (or whatever contains your rvm invocation lines). After that, try rvm use ruby-2.2 (or whatever), and if you don't get "RVM is not a function" error, then you should be good to go.
Note that under RVM you'll probably have to do gem install bundler manually for each distinct ruby version (and gemset), because ruby (and gemsets) under RVM live in their own worlds, and system bundler tends to be old. If you're reusing ruby installations and either not using or sharing gemsets, bundler may already be up to date.
So: use a login shell, do rvm use <your_favorite_ruby_version>, install bundler if necessary, then bundle install.
Last but not least, I like to use .ruby-version files so I don't have to switch rubies and gemsets manually, and I can tell if everything's working from the output of rvm info.
Where you using jruby before you installed rvm? Seems like your default ruby changed to jruby as opposed to whatever you where using before (system ruby?).
Try running
rvm use system
in the root of your rails project then try the bundle install and see if that fixes it. If it does then then can use setup .ruby-version files to control which version of ruby you use per project.
Or else type
rvm use system --default
to set your default ruby back to the system one and continue like you where preciously.
Related
After reading about Ruby gems and having no idea what rbenv or RVM was, I figured I should probably have one of the two.
I tried installing rbenv using Homebrew however it told me I had already installed rbenv. I always seem to have problems adding gems and usually end up using the sudo command to get it to work (which is a horrible idea I assume).
I discovered I had these problems when I was trying to add the braintree API gem and got an error whenever I tried to start the server.
Commands I tried:
gem install "braintree"
bundle install
sudo gem install "braintree"
The error received from running rails server was:
"/config/initializers/braintree.rb:2:in `<top (required)="">': uninitialized constant Braintree::Configuratio (NameError)"
To take it from the top, rbenv and RVM are Ruby version managers. This means that you can have multiple versions of Ruby installed on your computer at once and select which one you would like to use. I have used both and personally like rbenv's approach.
With that said I think you need to remove the quotes from around the name of the gem you are installing.
Also, in your Gemfile do you have the braintree gem listed? It should be as simple as gem 'braintree'.
If you have multiple versions of Ruby installed or even if you just have the system Ruby and a version installed with RVM or rbenv you may be starting your Rails server with the wrong Ruby version (ie it is missing the gem). You can see if it is using rbenv by typing which ruby and it should print something out with .rbenv/ whatever. If not you need to set rbenv as your current ruby. You can do that like rbenv global 2.1.1 where 2.1.1 is the version of ruby you installed with rbenv. If you haven't installed a version with rbenv you can use ruby-build and do rbenv install 2.1.1 or whatever version you want. Then when you launch your Rails server prefixing the command with bundle exec.
You can set a local ruby-version for your directory by executing rbenv local 2.1.1 once again where 2.1.1 is the version you want.
Reading the rbenv docs will go a long way.
To check if you are using rbenv, simply use this
rbenv
*check if 'rbenv' commands were listed
Same with rvm use
rvm
Run the command rbenv in terminal. If you have rbenv installed, it will list some help commands. If rbenv is not installed, it will output something like "No command 'rbenv' found"
Run the command rvm in terminal. If you have RVM installed, it will list some help commands. If rvm is not installed, it will output something like "No command 'rvm' found"
I recently started learning Rails using Ruby 1.9.3p385, and I'm trying to develop a small project with it.
I'm using Linux so I installed Ruby using RVM.
I developed a few pages, following some tutorials. I would like to upgrade my project to use Ruby 2.0.0. What do I have to do?
I installed Ruby 2.0.0 with RVM:
rvm install 2.0.0
Everything seems OK, so I tried to use it:
rvm use 2.0.0-p247
But when I try to run my Rails server using rails server, I get the following message:
bash: rails : command not found
I've read the RVM documentation about upgrading Ruby but I don't really understand what it does; I'm afraid of breaking everything.
Does it will upgrade my project in a way it will use Ruby 2.0.0 or what should I do?
Next, I will want to upgrade also to Rails v4.
Your gemset which comes with new Ruby version is empty. Try this:
gem install bundler # this will install bundler
bundle # this will use bundler to install required gems
rails server
Did you run rvm use 2.0.0-p247 or did you use rvm use 2.0.0-p247 --default? The later will set Ruby v.2.0 as the default for your system. Failure to do that will revert your Ruby to whatever RVM's default is the next time you log into your system or open a new terminal window.
When RVM installs a new version of Ruby, it installs only the default gems. It CAN upgrade a Ruby to another version, and optionally install the existing gems as it does so, but that's not what you asked it to do: rvm install 2.0.0 only installs Ruby. At that point you have to install the other gems you need, which would include Rails.
My general practice when installing various versions of Ruby and the gems I like is to use two command-line pipes to dump my existing gems, then (re)install them. First I switch to an existing Ruby whose gems I want to duplicate, then run:
gem list | cut -f1 -d' ' > ~/gem_list
Then I switch to the newly installed one, and run this:
xargs gem install < ~/gem_list
This does a completely clean install of the gems, outside of RVM's commands.
Why? Habit. Paranoia based on some "experiences" I had in the past with RVM.
Once that's all done and I have brand-spanking-new Ruby and gems, I'll proceed with running bundler or other housekeeping chores.
when you install a new ruby version, you have to reinstall all the gems for that version. start of by installing bundler first. Then run bundle in your rails root directory. When you encounter no errors, you're good to start the rails server. Good luck!
run bundle install on the application root, you need to reinstall all your dependencies for the new version of Ruby.
This has driven me crazy. I changed laptop and tried getting my Rails environment working again. Mac OS X has its own ruby, but I used brew and installed new. I installed rails 3.0.5, ran:
bundle install
Then:
rails s
I got this error:
Could not find aws-s3-0.6.2 in any of the sources
Run `bundle install` to install missing gems.
After bashing my head against a wall for a couple hours, I tried just manually installing the gems and it worked! So, apparently, rails and bundler are looking at different places for my gems. Both are from my brew install.
How can I figure out what each is looking at so I can use "bundle install" again?
Rails and Bundle are looking at the gems providing they are in the bundle.
Use the
bundle show
command to see the gems Rails is having access to via bundler.
Also you can examine the Gemfile.lock file.
The gemfile sources mainly from rubygems.org as supposed to rubyforge (which came up when i searched that gem on google). I think the gem command will check both. You can specify additional sources, as mentioned in the readme: http://gembundler.com/man/gemfile.5.html
Are you using pow? I've been having this issue with Pow starting up with one version of ruby, but not the version that I have RVM currently set to.
I have not tried it yet, but this issue on Github mentions the problem and refers people to the Pow trouble shooting here. I've pasted the contents below:
RVM
Incorrect ruby or gemset is being used
Create a .rvmrc at your project root. See rvmrc docs.
System-wide RVM install
If you have a system-wide RVM install and are getting the error LoadError: no such file to load -- bundler/setup, run rvm info to find out where rvm is installed on your machine, then do this:
echo "export POW_RVM_PATH=/usr/local/rvm/scripts/rvm" >> ~/.powconfig
Where /usr/local/rvm/ is the location of your rvm installation.
Then restart POW by killing it in the Activity Monitor or in Terminal.
I currently have rails 3.0.3 and am trying to download and use version 3.0.1. I've downloaded and installed RVM and inputted the following code in Terminal (I have a Mac OS X 10.6.5):
rvm use 1.8.7
rvm gemset create rails3.0.1
rvm 1.8.7#rails3.0.1
sudo gem install rails --version=3.0.1
I use sudo gems because of the user permissions, or my lack there of. Anyway, after I enter the last line of code: "sudo gem install rails --version=3.0.1" I get the following error:
Successfully installed rails-3.0.1
1 gem installed
Installing ri documentation for rails-3.0.1...
File not found: lib
Not only can I apparently not able to switch versions of rails, even though it appears as though I have multiple versions installed, every time I try to check to see what version of rails I currently have I get the following result:
rails -v
/Library/Ruby/Site/1.8/rubygems.rb:779:in `report_activate_error': Could not find RubyGem rails (>= 0) (Gem::LoadError)
from /Library/Ruby/Site/1.8/rubygems.rb:214:in `activate'
from /Library/Ruby/Site/1.8/rubygems.rb:1082:in `gem'
from /usr/bin/rails:18
Also, I've already installed Rdoc and Xcode (I've done research and other suggestions pointed to installing both). I'm a RoR newbie, and especially an RVM newbie, so I would love an explanation and a solution to this madness.
Thank you for reading!
I think you went off the rails (ha-ha) right here:
sudo gem install rails --version=3.0.1
The RVM documentation has this to say about that:
DO NOT use sudo...
to work with RVM gems. When you do
sudo you are running commands as root,
another user in another shell and
hence all of the setup that RVM has
done for you is ignored while the
command runs under sudo (such things
as GEM_HOME, etc...). So to reiterate,
as soon as you 'sudo' you are running
as the root system user which will
clear out your environment as well as
any files it creates are not able to
be modified by your user and will
result in strange things happening.
(You will start to think that someone
has a voodoo doll of your
application...)
I got a White Macbook and I have to go to a conference in 10 hours but I'm having a lot of problems.
First, I wanted to have Rails 3, so I used MacPorts to install Ruby 1.8.7. It worked well ;)
Then I was thinking I should install Rails 3, but no, no! It says:
$ sudo gem install rails --pre
ERROR: Error installing rails:
activesupport requires Ruby version >= 1.8.7.
What should I do? I already have 1.8.7!
First you need to install RVM, then the latest version of Ruby. Next you'll set that version of Ruby as the default. Finally, you'll install Rails b3.
Install RVM (http://rvm.beginrescueend.com/rvm/install/):
bash < <( curl http://rvm.beginrescueend.com/releases/rvm-install-head )
Install the latest Ruby (http://rvm.beginrescueend.com/rubies/installing/):
rvm install ruby-head
You can check which versions you now have installed with:
rvm list
Set the latest version of Ruby as default (replace 'ruby-1.9.2-head' with desired version):
rvm ruby-1.9.2-head --default
Make sure things are up to day, then install the Rails beta:
gem update --system
gem install rails --pre
You may have to install some gem dependencies before Rails will install.
To easily setup Rails 3 on osx machine the only thing you need to do is follow this brilliant (as always) Railscast, here for the transcription
You can also see comments to check for problems and eventually solutions.
You may have two different versions of Ruby installed. Try "gem env" or "sudo gem env" and see which version of Ruby it says you have.
Remove the older one if you have two installed. If all else fails, upgrade to 1.9.x, I believe it is recommended for Rails 3 anyway.
I would strongly recommend using RVM (Ruby Version Manager) to keep your Rails 3 separate from your Rails 2. (One example of Rails 2 conflicting with Rails 3: when you go to the command line to generate a Rails app, will it generate a Rails 2 app or a Rails 3 app? RVM allows you to keep them separate.)
Also, the latest Ruby 1.8.7 will probably not work with Rails 3, so you have to use an earlier patchlevel (248 works for me). Details are here: http://techiferous.com/2010/02/installing-rails-3-beta-with-rvm-and-ruby-1-8-7/
You should use rvm as others have said to manage multiple installations of Ruby and Ruby gems. (If you go that way, take the time to read rvm's documentation carefully.)
However, you should also get comfortable figuring out what version of Ruby your shell is seeing as the default and why. It sounds to me like your $PATH variable may not be properly updated. The $PATH variable is what determines which Ruby interpreter or gem command is the first seen, if you have more than one installed (as you now do). MacPorts will install new binaries into /opt/local/bin by default, and it should also alter your $PATH so that /opt/local/bin precedes /usr/bin (which is where Apple's out of the box Ruby lives).
I suspect that when you did sudo gem install, you were using /usr/bin/gem (which is the gem installer for /usr/bin/ruby rather than /opt/local/bin/gem (which would be the installer for MacPort's Ruby).
Check the output of echo $PATH, which ruby and which gem to see what's going on.
You should indeed use rvm, but as no one explained to you how to do this without rvm, here you go:
sudo gem install tzinfo builder memcache-client rack rack-test rack-mount \
abstract erubis activesupport mime-types mail text-hyphen text-format \
thor i18n rake bundler arel railties rails --prerelease --force
Based on your question and your responses to some of the answers, it sounds like you're not using the MacPorts version of Ruby. You should make sure that /opt/local/bin is in the front of your $PATH, before /usr/bin. Also, you should install RubyGems via MacPorts (sudo port install rb-rubygems) and make sure you're using the MacPorts gem. Then install Rails using the MacPorts gem.