I am building my first Rails application and want to include FileUtils in order to manage my Google sheets API (I got it to work in a standalone script).
However when I add FileUtils to my gemfile and use bundle install I get the following error:
ERROR: Error installing fileutils:
fileutils requires Ruby version >= 2.5.0dev.
And the most stable version of Ruby is 2.4.1.
So what am I missing?
Can you not use the version in the Standard Library? I'm not sure why you would need to add this to your gem file.
You should be able to use it with any standard Ruby installation:
require 'fileutils'
So what am I missing?
You are missing the fact that the gemification of the stdlib has only just now begun and is targeted at Ruby 2.5/3.0, so naturally that's what those Gems require.
Unless you are on Ruby 2.5, just use the stdlib version.
If you realy need to specify the fileutils gem in your gemfile, use:
gem 'fileutils', '0.7'
as 0.7.1 requires a new Ruby according to
https://rubygems.org/gems/fileutils/versions/0.7.1
Related
I know the question to this is probably very straight forward, but Im a bit new to rails, so please bear with me. I have had rails version 5.1.5 on my Mac and I need to update rails to version 5.1.6 and I'm not able for the life of me to do that.
I tried
`sudo gem install rails -v 5.1.6`
but this gives the error
ERROR: Failed to build gem native extension.
Using gem list gives that I have
rails (5.1.5, 5.1.4)
I also tried bundle update rails
I keep getting Could not locate Gemfile
What am I doing wrong??
gem is the native package manager for Ruby.
Bundler (bundle) is a gem to manage bundles of gems via a Gemfile.
I recommend you use a version manager for Ruby like rvm, rbenv or chruby and also install xcode and the commandline-tools package of xcode. Some gems have dependencies written in C that need to be configured and compiled, all of that and some more comes with xcode.
I currently have Ruby 2.2.6 and Rails 5.0.1 installed on my Windows 10 machine. I have cloned an existing project that has the following settings included in its Gemfile:
# Lock-in Lang and Framework:
ruby '2.2.0'
gem 'rails', '4.2.0'
I'm having a surprisingly hard time figuring out how to get Ruby 2.2.0 and Rails 4.2.0 installed. Ruby has good documentation of different installation options, but I think I've exhausted the Windows options without any success. Here are a couple I tried:
Installers: I couldn't find an option for downloading either from RailsInstaller, RubyInstaller, and Bitnami.
RVM: I tried (unsuccessfully) following this blog post to install cygwin so that I could use RVM, but then saw in the comments that the author now recommends spinning up a linux VM rather that using this method.
Pik and Uru: It appears Pik is no longer maintained, and I couldn't figure how to download new versions and ruby and rails with Uru as opposed to managing already downloaded versions.
EDIT: I also tried simply changing the version numbers for ruby and rails in the Gemfile to 2.2.6 and 5.0.1. When I do this I (very understandably) get a message when I try to use a rails command saying I need to run bundle update rails. When I run that rails update I get the following error: Bundler could not find compatible versions for gem "rack". I've done some googling on that option, and it looks like resolving that issue might be possible but requires some more involved tinkering with my Gemfile configuration.
I think my next option is to install Ruby from the source, but I wanted to throw a question up here first to make sure I'm not missing an easier method. So my question is - is it really this hard to get an older minor release of ruby and rails installed on Windows? I realize that the majority of users are probably looking for the most recent release, but it doesn't seem to me that my use case is terribly unique.
The oldest available Ruby 2.2.x via RubyInstaller is 2.2.1
So, the answer to your question is, "Yes, you'll have to build from source."
But then again,
v2.x of gem "rack" requires at least Ruby v2.2.2
And depending on what other gems are included in your Gemfile, you'll still have to reconfigure your Gemfile to get this app running.
So the best solution is probably to use the latest patch version of Ruby 2.2.x and lock rails to 4.2.x. (The app may not be compatible with Rails 5.x)
# Lock-in Lang and Framework:
ruby '2.2.6'
gem 'rails', '~> 4.2'
Then run bundle install to install all the gems required by the Gemfile
I am trying to load (require) the httparty gem into a Ruby file but keep getting an error and am unsuccessful.
Below is the error copied:
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- httparty (LoadError)
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /Users/neilricci/Desktop/test.rb:1:in `<main>'
Below is where the httparty gem file is located on my computer:
/Users/neilricci/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/httparty-0.13.7/lib/httparty.rb
Issue was resolved by installing httparty with sudo, which is weird because I installed httparty as the main admin.
sudo gem install httparty
How are you requiring the HTTParty gem in your code? Sometimes an error occurs when you're including your gems with capital letters, that's to say a require "HTTParty" will be clearly different than require "httparty".
It can produce a 'require': cannot load such file -- HTTParty (LoadError), what's a name difference; possible solution is to refer your gem require in complete lowercase letter.
Another possible cause could be that your ruby version isn't compatible with what the gem needs, maybe you're running your piece of code with a previous version minor than what the gem needs to work; possible solution is to check what's the Ruby version dependency of the gem that's giving you problems, at the time of writing this the last version of HTTParty is the 0.14.0 what requires a version of Ruby equal or more actual than 1.9.3 (>= 1.9.3)
If your HTTParty gem version is old you're going to receive error messages with undefined methods, here the solution is obvious, check what version do you have and uninstall it using sudo gem uninstall httparty-gem and then install the new version using sudo gem install httparty-gem (sudo is to prevent possible future errors with the propietary who has installed the gem), or if you want you can just install it and have those two or more versions of the gem.
In my case I had put require 'httparty' on my class but still give me an error. I tried to Install and Uninstall httparty gem without any progress. Finally I could resolve the problem by adding gem 'httparty' line to my Gemfile file followed by running bundle install from command prompt.
I am using rails 5.2.3 with ruby 2.5.1
Try installing the gem:
gem install httparty
Your code seems to be running in Ruby 2.0.0, but the gem seems to be installed for Ruby 2.2.3.
Make sure your Ruby version is properly selected through rvm or chruby or whatever you personally use to manage your Ruby versions, and make sure the HTTParty is installed for the same version your code is running in.
Remove the code require 'httparty' wherever you have added.
I am newbie to Rails development and working with Spree Commerce bitnami Stack VM instance. I am trying to install spree extension and the instructions says to make configuration changes to application Gem file which I cannot find in the webserver directory
Running Rails 2.3.5
Spree 0.9.4 version
The reason why you can't find it because Gemfile is a standard from Rails 3+ and you're using a Rails2 app. Rails3 uses Bundler which takes cares about all Gems for your app.
In Rails 2 gem dependency definition is different. It doesn't have Bundler so "bundle install" also won't work in your case.
Instead you need to add Gem dependency to config/environment.rb like this:
config.gem 'your_gem_name_here'
also you need to install the Gem manually, so not like in Rails3 where Bundler installs it. Use this in shell:
gem install your_gem_name
In general it's a good idea to update the app to Rails3, I'd recommend it because as I saw this Gem you wanna use doesn't have earlier release.
I have currently moved to a appplication on rails 2.3.4 and ruby 1.8.7 using rvm.
There are a no of gems installed in the app.When i do gem install gem_name ,it installs it but iam not sure whether the gem version is compatible with my app.The gem versions are not specified in case of many gems listed config/environment.rb.Iam unable to figure out ,how to install the correct version as unable to run the application till now. Any suggestions are welcome..
To provide true gem-consistency in your app, you should consider use Bundler to manage these dependencies. The Gembundler site has a good guide on setup for rails 2.x apps.
Once you have your dependencies in bundler, you can start to work out what is compatible and what isn't. In the case of third-party gems, you can search for them on the RubyGems site, and work out which version was the last to be released before Rails 3.x was released. Of course most gems will just work, but any breaking gems will possibly need to run an older version.
I would use Bundler, and add the gems to the Gemfile. Here is the syntax to use a specific version:
gem 'gem-name', '1.0.4'