I got this error:
Could not find gem 'mysql2 (>= 0, runtime)' in any of the gem sources.
Try running `bundle install`.
when trying:
rails script/generate scaffold post title:string
I am on a mac osx, rails 1.8.7, 3.0
On ubuntu you may need to install library for mysql first.
sudo apt-get install libmysqlclient-dev
And then you can install
gem install mysql2
or even better way is to use rvm
rvm gem install mysql2
You use rails script/generate … with rails 3.0? Maybe you upgraded rails 2.x project? With rails 3 you should use rails generate … or shorter rails g ….
About missing gem: run bundle install as asked for :)
If you use the Mac, this will help you (I also had been on this error for 2 hours).
brew install mysql
brew install openssl
gem install mysql2 -v '0.5.2' -- --with-ldflags=-L/usr/local/opt/openssl/lib --with-cppflags=-I/usr/local/opt/openssl/include
bundle install
The main point is that you have to first install the openssl for setup the mysql2 gem on Mac.
Related
Ruby version: 2.1.5p273
Rails version: 4.2.0
Gem Version: 2.2.2
OS: Windows 7 x64
Hello, I am very very new to rails programming. I am trying to start learning, but cannot because of these problems.
I created a rails app
I type: >rails new app
I then navigate to the created folder
I type: >rails server
It tells me
"Run 'bundle install' to install missing gems."
I do so and it than tells me:
"Make sure that 'gem install debugger-linecache -v '1.2.0' succeeds before bundling'"
after installing said gem I try bundle install again, but it than repeats the same error with a different gem.
""Make sure that 'gem install *random gem* -v '*random version*' succeeds before bundling'""
I hardly have any idea what I'm doing here. How can I get this server running?
i started to write an answer, and then saw you comment,
but for everyone out there who need an answer and didn't notice your comment:
Try this,
first run:
bundle update
and then try to bundle install
if its not working, install bundler:
gem install bundler
and now run bundle install
Solved by using the following two commands: gem update --system gem install bundler
Hi i'm new to ruby on rails
I have 3 ruby version in my computer.
In a project i had to use rails 3.2.1 and ruby 1.9.2
So I switched using rvm use 1.9.2 in terminal. But after that my rails commands are not detected.
$ rails g model abc
The program 'rails' is currently not installed. You can install it by typing:
sudo apt-get install rails
Why is this happening? And how to solve this?
You may need to differentiate your gem set that contains that specific version of rails from the old ones.
rvm use 1.9.2#new_gem_set_of_yours --create --default
And then retry installing the 3.2.1 rails
gem install rails --version 3.2.1
Or specify the new rails version in your Gemfile and let Bundler take care of it
gem 'rails', '3.2.1'
and run bundle install.
Type in your terminal
gem install rails -v 3.2.1
if it does not work, first try
rvm install 1.9.3
then
rvm rubygems current
and repeat.
First of all I've gone through dozens of posting here on SO and google and haven't been able to find an answer.
I'm trying to install mysql2 with bundler and it won't do it.
Running on Ubuntu Server 11.04 Natty
Here's some background info:
ruby -v
ruby 1.8.7 (2012-02-08 patchlevel 358) [x86_64-linux]
gem -v
1.8.24
rails -v
Rails 3.2.5
$ mysql --version
mysql Ver 14.14 Distrib 5.1.62, for debian-linux-gnu (x86_64) using readline 6.2
I have gem "mysql2", "~> 0.3.11" in my Gemfile
When I do bundle install it goes through the process and it finishes successfully (No Errors) but it doesn't install mysql2. When I do bundle show, mysql2 is not listed.
I've tried a gazillion of things recommended here and on forums and still can't get mysql2 to install with bundler.
Any ideas?
Thanks.
For mysql2 you need to install the dev files on your server.
try first:
sudo apt-get install libmysqlclient-dev
Then check first your GemFile in your RoR App Dir - I have this line in my GemFile:
gem 'mysql2', '0.3.11'
run bundle:
bundle install
or try the command from Emily first then run bundle install:
gem install mysql2 -v=0.3.11
bundle install
I hope it helps
So after many tries, reading, and pulling my hair out I found out what was the problem, so I'm posting it for those that might run into the same situation.
The reason why bundler wouldn't install mysql2 is because the gem was inside this platforms structure, see below:
platforms :mri_19, :mingw_19 do
group :mysql do
gem "mysql2", "0.3.11"
end
end
So all I did was to move just gem "mysql2", "0.3.11" by itself to the top of the Gemfile and run bundle install and that did it! Now mysql2 is listed under bundle show and my rails application is running now.
Thanks every one that tried to help!
Somehow my rails installation hides itself successfully...
I have:
ruby 1.9.2p290 (2011-07-09 revision 32553) [i686-linux]
rvm 1.10.0-pre
gem 1.8.10
and I try to install rails:
sudo gem install rails
it works fine:
Successfully installed rails-3.1.3
1 gem installed
Installing ri documentation for rails-3.1.3...
Installing RDoc documentation for rails-3.1.3...
when I do:
rails - v
I get
The program 'rails' is currently not installed. You can install it by typing:
sudo apt-get install rails
Also, when I do
rake
in a rails app root directory, I get:
Missing the Rails gem. Please `gem install -v= rails`, update your
RAILS_GEM_VERSION setting in config/environment.rb for the Rails version
you do have installed, or comment out RAILS_GEM_VERSION to use the
latest version installed.
executing
gem install -v= rails
raises an error:
ERROR: While executing gem ... (ArgumentError)
Illformed requirement ["="]
So apparently it is sitting somewhere and cannot be seen by my environment. I guess installing via apt-get is not an option as I don't want to confuse gem...
Any ideas?
Cheers
Mac
Do not use sudo.
Just gem install rails
Use RVM instead of the packaged ruby/gems distribution. http://ryanbigg.com/2010/12/ubuntu-ruby-rvm-rails-and-you/
While trying to install Rails 3, I get the following error:
command run: sudo gem install rails --pre
error'd now with:
Successfully installed rails-3.0.0.rc2
1 gem installed
Installing ri documentation for rails-3.0.0.rc2...
File not found: lib
Or if you don't want to worry about running versions side by side you can do
gem update rails
At least it worked for me.
Rails 3 is out of beta/rc now, so try:
gem install rails --version 3.0.0
It should work on Ruby 1.8.7 and 1.9.2-p0.
I haven't personally seen that issue, but you could try and get around it by using the --no-ri option.
sudo gem install rails --pre --no-ri
There's also a --no-rdoc option if you have trouble with that too.