Hello everyone I am new to rails I am following lynda tutorial and I am trying to install mysql2 but the error is showing I have look on various page of stack overflow but was not able to resolve it.My Error is
ERROR: Could not find a valid gem 'mysql2' (>= 0), here is why:
Unable to download data from https://rubygems.org/ - no such name (https://api.rubygems.org/latest_specs.4.8.gz)
On Windows, you need to use the following:
Download C-Connector & unzip to a non-spaced path on your system
Install the gem referencing the new path:
gem install mysql2 --platform=ruby -- --with-mysql-dir="C:/path/to/your/c-connector/install/no/spaces"
This should install the gem, allowing you to proceed with your other installation.
--
The reason this has to be done on Windows is due to the fact that the mysql2 gem requires an external set of dependencies (the c-connector plugin), which Windows does not have installed by default.
Linux users can use apt-get, and Mac users brew to get the dependencies; Windows users have to download it themselves.
If you follow the steps above, you should get the mysql2 gem installed.
I think there is some typos in your gemfile, Check if you have type correct version mentioned in the tutorial. mysql gem should look like below.
gem 'mysql2', '~> 0.3.11'
Related
I want to install ruby on rails in offline mode (i.e. without internet connection). So I downloaded railsinstaller-3.2.0.exe from http://railsinstaller.org/en and installed it. By the end, I had ruby installed but in order to have rails installed I ran
gem install rails
and faced these errors: (meaning command needs internet connection)
ERROR: Loading command: install (ArgumentError)
unknown encoding name - CP720
ERROR: While executing gem ... (NoMethodError)
undefined method 'invoke_with_build_args' for nil:NilClass
I mean is there any solution like downloading gems with another computer connected to internet and then copying files in the proper location in the installed directory of gems.
Please help me if you have any idea.
As said in a comment, it's a gem (lib) dependency issue.
You might want to look into installing the bundler gem library to manage dependencies for you, with bundler you would just have to run, bundle install and it would download all the required gems for you including any gem dependencies.
You can install bundler simply, just run
gem install bundler
Then in your rails project directory, just run bundle install.
Often to run a project (like rails for example) you might have to start it with
bundle exec rails start
To install Gem's on a non-internet connect computer you might want to refer to this answer on just that problem.
This is the website where you can find all available ruby gems. Ruby
gems download. Find the one you are interested and download it.
Then move the gem in a directory of your choice and cd into that from
the command prompt. I am using C:/ruby193/bin/pony-1.4.gem
Let's say that the gem we are interested in is the pony gem (smtp
email).
Just type gem install pony-1.4.gem
and you should get it installed manually unless you have a restricted
acc with not adequate administrative privileges.
You can also refer to the official documentation on the matter.
I'm trying to install Ruby, I followed the installation guide well, but when I tried to run the server by the command:
ruby bin/rails setup
after I created the controller called blog as described in the instructions, it gave me an error in red and a text in yellow:
Error:
Could not find gem uglifier <>= 1.3.0 in the gems available on the machine.
Yes! I know that this is a Googleable question but all I can get are solutions for people with internet access on their PC.
But unfortunately, my computer doesn't have a working Internet connection. I'm posting this question from my phone. So I'm unable to install uglifier(if that's the required thing to do) through the command prompt. Many thanks.
Please could you check if your Gemfile has the following gem
gem 'uglifier'
If the Gem is not present add it to your Gemfile, if you already have it in your Gemfile please run:
bundle install
After that you should check if the bundler is installing the uglifier gem.
Hope that helps,
I just started learning Ruby on Rails and i'm going through Lynda Ruby on Rails 4 Essential Training. So far everything was looking really good (no errors while installing everything), but when i tried to run Webbrick server i get error.
Can someone please help me to debug this server log.
I'm working on windows 8
ruby -v
ruby 2.0.0p481 (2014-05-08) [x64-mingw32]
rails -v
Rails 4.1.5
gem --version mysql2
2.4.1
Because error is too big i'm giving you a link to txt file.
Click here
Okay, you mention you're using Windows, and you're a newbie, so I'll give you some information on how to get the infamous mysql2 gem working on your system (which is likely to be the problem):
MYSQL2
Because Windows does not come with many developer dependencies (including MYSQL), installing gems such as mysql2, rmagick and curl don't work out of the box
Instead, you have to first install the development dependencies (often referred to as "header files") in order to install the gem. This is how you do it with MYSQL2 (by the way, we've written a tutorial about this here)
--
You need to ensure the MYSQL2 gem installs on your Windows system. This is done using 3 steps:
Install the MYSQL C-Connector header files
Install the MYSQL2 gem, referencing the newly installed MYSQL C-Connector files
Copy libmysql.dll from your MYSQL folder to your Ruby folder
Firstly, you need to install the mysql c-connector header files:
Please note you must ALWAYS install the 32 bit version of the C-Connector library, regardless of which version of Windows you're using. Also, you need to install to a file path which has no spaces
Once you've done this, you then need to be able to install the mysql2 gem, whilst referencing the newly installed MYSQL library:
gem install mysql2 --platform=ruby -- '--with-mysql-dir="C:\mysql-connector-path"'
This gives you the ability to install the gem by referencing the files it needs. That's why you need to install the dependencies without any spaces.
If this installs the gem, you then need to copy the libmysql.dll file:
Now this is just a presumption
You need to ensure you have the gem installed in order to get the server running.
There is a patch for the related issue: https://copy.com/CHZ4eT4us6f1/mysql-connector-c-noinstall-6.0.2-winx64.zip where it's discussed in https://github.com/brianmario/mysql2/issues/372
You can download the file at the above link and extract to the disk, assume you unzip to "D:" drive as D:\mysql-connector-c-noinstall-6.0.2-winx64
Try to install mysql2 gem again.
gem install mysql2 --no-rdoc --no-ri -- '--withmysql-dir="D:\mysql-connector-c-noinstall-6.0.2-winx64\bin" --with-mysql-lib="D:\mysql-connector-c-noinstall-6.0.2-winx64\lib" --with-mysql-include="D:\mysql-connector-c-noinstall-6.0.2-winx64\include"'
Then, copy libmysql.dll file from D:\mysql-connector-c-noinstall-6.0.2-winx64\lib folder to D:\Ruby\bin\ folder.
Finally, try to start rails webrick server again.
I'm using Ruby on rails (RubyMine) and I try starting my project.
Which tells me the error "Could not find gem 'mysql2 (~> 0.2.6, runtime)' in any of the gem sources listed in your Gemfile. (Bundler::GemNotFound)".
I've done sudo gem install mysql which gives me
"Error installing mysql:
ERROR: Failed to build gem native extension.
Gem files will remain installed in /var/lib/gems/1.8/gems/mysql-2.8.1 for inspection.
Results logged to /var/lib/gems/1.8/gems/mysql-2.8.1/ext/mysql_api/gem_make.out
"
What should I do?
You're probably missing the development headers for MySQL. Often this is shipped as an optional package to install. You may need to install mysql-dev or mysql-devel depending on your package manager.
You might also be missing a compiler, so check that you have the required dependencies for gem such as make and gcc.
You might be missing the Ruby development headers as well. On my Ubuntu 11.04 box I have the following aptitude package which is needed for native gem compilation:
ruby1.9.1-dev
Alright, I've been trying to install Rmagick on a Windows 7 x64 machine pretty much all day. I've checked out every single tutorial on Stack Overflow and other sites, but I keep getting an "Invalid Drive Specification" error no matter which tutorial I follow. My environment came from http://railsinstaller.org/. Has anyone successfully installed Rmagick recently that can point me in the right direction? Thanks, this is driving me crazy but I really have to get it working.
First and most important, when reporting issues or asking for help, always include version information about what you're trying to install, specially Ruby.
It seems you're installing using RailsInstaller, but since you didn't mention if is the 2.0 preview version or the stable one, I'll assume you used the stable one, which is based on Ruby 1.8.7-p334.
Now, RailsInstaller already includes the needed pieces: Ruby and RubyInstaller DevKit component, so going to skip the steps about installation of that and jump directly to RMagick itself.
To successfully install RMagick gem, you need ImageMagick binaries with development headers, as documented in RubyInstaller's Tutorial wiki page, which links here
Please download 32bits version of ImageMagick, as Ruby is 32bits.
For my test I've downloaded the installer version ImageMagick-6.7.0-8-Q16-windows-dll.exe
Once downloaded and installed in a path without spaces and I've selected the option Install development headers and libraries for C and C++.
Then open a new Command Prompt, ensure Ruby is available (checking with ruby -v) and after performed the following command:
gem install rmagick --platform=ruby -- --with-opt-lib=C:\ImageMagick-6.7.0-Q16\lib --with-opt-include=C:\ImageMagick-6.7.0-Q16\include
That command is going to take considerable amount of time (took 1 minute on my Core 2 Duo) but the end result was:
Fetching: rmagick-2.13.1.gem (100%)
Temporarily enhancing PATH to include DevKit...
Building native extensions. This could take a while...
Successfully installed rmagick-2.13.1
1 gem installed
Now you can verify RMagick installed successfully using IRB:
irb(main):001:0> require "rubygems"
=> true
irb(main):002:0> require "rmagick"
=> true
irb(main):003:0> Magick::Version
=> "RMagick 2.13.1"
Now, if you're using Ruby 1.9.2, last RMagick release is not compatible with it and you will need to build from source. There is another tutorial on RubyInstaller wiki that covers that, but please read this thread at RubyInstaller group were we discuss the issues.
Hope all this helps.
This above post did not work for me, the key for me was using GitBash wich comes with RailsInstaller, and also includes Devkit.
Install railsinstaller -> www.railsinstaller.org (I installed it to c:\Rails)
Install ImageMagick -> ImageMagick-6.7.3-8-Q16-windows-dll.exe (I installed it to c:\ImageMagick)
Open GitBash
$ gem install rmagick --platform=ruby -- --with-opt-lib=c:/ImageMagick/lib --with-opt-include=c:/ImageMagick/include
Temporarily enhancing PATH to include DevKit...
Building native extensions. This could take a while...
Successfully installed rmagick-2.13.1
1 gem installed
Installing ri documentation for rmagick-2.13.1...
Installing RDoc documentation for rmagick-2.13.1...
Also, in the gemfile I have commented out gem 'rmagick' in the development group
This is what my gemfile looks like
group :development do #this is used on localhost
gem 'mysql2'
gem 'paperclip'
#gem 'rmagick' #dont need this
gem 'devise'
end
group :production do #this is used on heroku
gem "pg" #this is postgresql used on heroku
gem "aws-s3" #this is used for amason S3 filestorage
gem 'paperclip'
gem 'rmagick'
gem 'devise'
end
We just had this problem with Windows 7, Ruby 2.0 & Rails 4.0
This tutorial works really well:
Download the latest ImageMagick installer from ImageMagick.org (as of writing, "[ImageMagick-6.8.7-0-Q16-x86-dll.exe][3]" -- the complete installer (not the binaries))
Once downloaded, install ImageMagick without any white spaces in the file path (E.G C:/ImageMagick) with the following options checked:
Add Application Directory To Your System Path
Installer Development Headers For Libraries C & C++
In the Ruby CMD, install the RMagick Gem with the correct file paths:
gem install rmagick --platform=ruby -- --with-opt-lib=**c:/ImageMagick-6.7.0-Q16/lib** --with-opt-include=**c:/ImageMagick-6.7.0-Q16/include**
This should work for you
I did install it about a month ago. One of many errors I had to overcome was the "Invalid drive specification"
I've just started a blog with a post about installing RMagick on Win7 based on my self-answered question here.
One note though: I used ruby 1.9.2 and railsinstaller seem to use 1.8.7.
If I remember it right, this error could be caused by spaces in your image magick installation path.
I don't have enought privileges, sorry for posting my comment to Luis Lavena's answer here.
One solution that worked for me was running Luis Lavena's solution from "Command Prompt with Ruby and Rails" (from the Windows start menu). It loads all necessary configurations.