After going step by step (installed both ruby and rubygems properly) to install watir-webdriver, I am facing following error:
ERROR: Error installing watir-webdriver:
ERROR: Failed to build gem native extension.
/usr/bin/ruby1.9.1 extconf.rb
<internal:lib/rubygems/custom_require>:29:in `require': no such file to load -- mkmf (LoadError)
from <internal:lib/rubygems/custom_require>:29:in `require'
from extconf.rb:4:in `<main>'
Please help me resolve this and do let me know what made this happened?
Not sure how you are installing ruby on your Ubuntu machine but may I recommend the Ruby Version Manager.
https://rvm.io/
this will allow you to install different versions of ruby on your machine and switch between them as well as gems etc.
here is a quick guide I wrote for installing watir webdriver in Ubuntu via RVM:
Ubuntu requires the use of a Ruby Version Manager. To do this we will need to first install both the Curl package and Git-core.
To do this use the following command:
sudo apt-get install curl git-core
Upon success we will need to download the Ruby Version Manager application. This application allows us to install multiple versions of ruby as well as switch between. It also provides a Gem manger. Recommended to Google to read up on the commands and features within RVM. To install RVM use the following:
bash -s stable < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer )
We can also install packages within RVM and we will require the use of openSSL:
rvm pkg install openssl
Then installing Ruby itself:
rvm install 1.9.3-p125 --with-openssl-dir=$rvm_path/usr
Best to test this is all working with:
irb
When all clear we can install the Gem, we need to install it within the RVM with the follow:
rvm do gem install watir-webdriver
If installed correctly we should be able to use watir to drive firefox which is already installed on ubuntu.
I am not Linux/Ubuntu expert but the error message says you do not have build tools installed.
Related
Even I have installed ruby-dev and ruby-make but still giving same error ? how to fix the error ?
sudo gem install mechanize
Building native extensions. This could take a while...
ERROR: Error installing mechanize:
ERROR: Failed to build gem native extension.
current directory: /var/lib/gems/2.4.0/gems/unf_ext-0.0.7.5/ext/unf_ext
/usr/bin/ruby2.4 -r ./siteconf20180417-8728-15wdd1s.rb extconf.rb
mkmf.rb can't find header files for ruby at /usr/lib/ruby/include/ruby.h
extconf failed, exit code 1
Gem files will remain installed in /var/lib/gems/2.4.0/gems/unf_ext-0.0.7.5 for inspection.
Results logged to /var/lib/gems/2.4.0/extensions/x86_64-linux/2.4.0/unf_ext-0.0.7.5/gem_make.out
You don't have the source code for Ruby so when it attempts to compile the gem it fails. It's looking for /usr/lib/ruby/include/ruby.h but that file isn't present on your system.
Generally, it's not a good idea to use the system version of Ruby. (for this reason, and others) You should use a Ruby manager to install Ruby into your user profile, as this will make compiling gems a lot easier.
For example, you can use RVM to install Ruby:
\curl -sSL https://get.rvm.io | bash -s stable
This will install the latest version of rvm, which you can then use to install Ruby 2.4:
rvm install 2.4
You can install nearly any version of Ruby by specifying its version, for example Ruby 2.5:
rvm install 2.5
Afterwards, running ruby will automatically run the version installed by RVM. And since it's installed in your profile, you don't need to use sudo for any operations. (and you should never use sudo when using rvm or Rubies installed by rvm)
In your case, you would then be able to run gem install mechanize successfully because it would be using the Ruby installation in your home directory that includes a copy of the source code and header files.
If for some reason you can't use RVM or don't want to use RVM, then you need to have the Ruby header files installed. The way to install these headers varies by operating system so there's no one answer I can give you. If your OS is a Debian-based version of Linux, for example, you can install the headers with:
sudo apt-get install ruby2.4-dev
More information is available in another answer on stackoverflow.
I am trying to install a ruby gem in My Machine using xcode where I call a shell script.
cd "/Users/Desktop/gemfolder"
gem install somegem.gem
I am getting an error like this:
While executing gem ... (Errno::EACCES)
Permission denied - /Library/Ruby/Gems/1.8
Any workaround for it I am a newbie to ruby so don't know what to do anyhelp will highly appreciated.
Being sudo might fix your problem, however when you are installing gems , its not a good idea to install them as sudo, so the preferred way of installing ruby on any machine is to install rvm (Ruby Version Manager) first and then install your ruby version.
Main advantages of having a ruby version manager are,
1 - allows you to install multiple ruby versions side by side
2 - allows you to install gems for each ruby version (via gemsets)
So to install rvm in your mac, check here
list of ruby version managers
I just installed ruby 2 on MacMountainLion, how to install gems? Actually I have both installed but there is something wrong. Maybe a fresh installation would solve.
macbook:~m$ gem install rails
ERROR: Loading command: install (LoadError)
cannot load such file -- openssl
ERROR: While executing gem ... (NoMethodError)
undefined method `invoke_with_build_args' for nil:NilClass
macbook:~ m$ ruby -v
ruby 2.0.0p0 (2013-02-24 revision 39474) [x86_64-darwin12.2.0]
macbook:~ m$ gem -v
2.0.3
macbook:~ m$
I had the same problem, but fixed it as follows:
Apparently OS X Mountain Lion has an older version of OpenSSL than Ruby 2 will tolerate. Download and install the latest OpenSSL using ./Configure darwin64-x86_64-cc --prefix=/usr/local --openssldir=/usr/local/openssl; make; sudo make install. Then build Ruby using ./configure --with-openssl-dir=/usr/local/openssl; make; sudo make install. Ruby's configure complains that --with-openssl-dir is an unknown option, but the build apparently uses it anyway because anything that depends on SSL, including gem installs, now works.
Installing gem like rails needs lot of dependent libraries which you have to download and install it manually
Alternatively you can try using Homebrew to install all the dependent libraries. If you are new to ROR development I strongly recommend you to use rvm to manage different versions of ruby
Once you have installed all the necessary dependent libraries using Homebrew then Its fairly straight forward to install a gem, execute the following after replacing "gemname" with the gem you are interested in
gem install <<gemname>>
I had to do a lot of juggling when I tried to install Ruby 1.9.3, and it is mentioned in community that ruby1.9.1 is the package to be installed for Ruby 1.9.3. Now, if i run ruby, I get
<internal:gem_prelude>:1:in `require':
cannot load such file -- rubygems.rb (LoadError)
from <internal:gem_prelude>:1:in `<compiled>'
What can I do?
FYI, I uninstalled everything in my comp by sudo apt-get remove --purge ruby1.8 libruby1.8
Then I installed Ruby1.9.1 by sudo apt-get install ruby1.9.1 libruby1.9.1
What do i do?
EDIT:
After the comments, I used rvm to install newer ruby 1.9.3, ANd now everything is perfect.
MORAL:
dont use apt-get for ruby. Use rvm, gem and other ruby tools. It's brilliant.
If you installed Ruby system-wide with apt then the latest RubyGems won't be included in the install. Ruby is the language, RubyGems is the package manager which has to be installed separately.
To install RubyGems just go here and follow the instructions:
Download from above.
Unpack into a directory and cd there
Install with: ruby setup.rb (you may need admin/root privilege)
For more details and other options, see: ruby setup.rb --help
I have installed Ruby on Rails on my Ubuntu 10.04 Server by official tutorial: https://help.ubuntu.com/10.04/serverguide/C/ruby-on-rails.html
But I have some troubles with it. Please, help me!
1) I can't install ANY gem!
sudo gem install sqlite3-ruby
returns
ERROR: Error installing sqlite3-ruby:
ERROR: Failed to build gem native
extension.
/usr/bin/ruby1.8 extconf.rb
extconf.rb:3:in `require': no such
file to load -- mkmf (LoadError) from
extconf.rb:3
Gem files will remain installed in
/var/lib/gems/1.8/gems/sqlite3-1.3.3
for inspection. Results logged to
/var/lib/gems/1.8/gems/sqlite3-1.3.3/ext/sqlite3/gem_make.out
2) When i'am trying to get Rails version by command
rails -v
Server prints:
getopt: invalid option -- 'v'
Terminating...
If you are not set on using the packages in the Ubuntu repos(and I see no reason why you'd be), I'd suggest following this guide:
http://ryanbigg.com/2010/12/ubuntu-ruby-rvm-rails-and-you
Consider going through and making sure your sqlite3 libraries are installed. It looks as though you may be missing the required dependencies to build your gem. In this case you might try running this before installing your gem:
sudo apt-get install libsqlite3-dev
Also, try
rails --version
instead.