Cannot install state_machines gem in Windows environment - ruby-on-rails

I am new to Rails and would like to check how Spree ecommerce solution looks like before the customization. That's why I installed Ruby from RubyInstaller, DevKit, Rails, Spree etc.
During installation of state_machines gem, below error appears and the gem is eventually not installed.
C:\>gem install state_machines
ERROR: While executing gem ... (Errno::EINVAL)
Invalid argument # rb_sysopen - C:/Dev/Ruby/lib/ruby/gems/2.1.0/gems/state_m
achines- 0.2.2/test/unit/node_collection/node_collection_after_being_copied_test.rb
This has impact on the bundle install of spree project later on:
Errno::EINVAL: Invalid argument # rb_sysopen - C:/Dev/Ruby/lib/ruby/gems/2.1.0/g
ems/state_machines-0.2.2/test/unit/node_collection/node_collection_after_being_c
opied_test.rb
An error occurred while installing state_machines (0.2.2), and Bundler cannot
continue.Make sure that `gem install state_machines -v '0.2.2'`
succeeds before bundling.
Current ruby version installed is:
ruby 2.1.5p273 (2014-11-13 revision 48405) [i386-mingw32] + devkit
rails version is 4.2.0
I am running on Windows environment, without any possibility to move to Linux.

I ran into this too.
Looks like state_machines has some test case files that have a newline in the name.
I'd bet that is the cause of the issue.
I've submitted a pull request over here: https://github.com/state-machines/state_machines/pull/11
In the meantime, my branch doesn't have the issue: https://github.com/jeff-hamm/state_machines
The specific fix (for the moment, until the pullrequest is accepted) is:
git clone https://github.com/jeff-hamm/state_machines
cd state_machines
bundle gem state_machines
rake install
After doing that, 'gem install spree_core' worked just fine on windows.
Keep in mind I am not planning on keeping my branch up to date (I will delete it if the request is accepted), so, that clone url won't be ideal for long

Related

omniauth requires Ruby version >= 2.1.9. issue while installing gem file

Got an error after typing "bundle install" with some sort of issue with the Ruby version. Have been installed many-many gems so far and never got incompabilities with the Ruby version.
What's the best way to upgrade the Ruby version to get back on track with the "bundle install" without putting the app at "risk"?
Here it is what I have done:
1st - Added the twitter omniauth gem to my gemfile.
2nd - Created a omniauth.rb file in the app/config/initializers folder.
3rd - Typed the "bundle install" command and got the following error: "omniauth requires Ruby version >= 2.1.9."
Dependencies can specify a required_ruby_version in their .gemspec file. In this case, one of your sub-dependencies (omniauth - a sub-dependency of omniauth-oauth, which is in turn a sub-dependency of omniauth-twitter) has had such a requirement since v1.5.0.
To get a working install, you've got two options:
Pin to an older version of omniauth, by adding gem "omniauth", "~> 1.4.2" to your Gemfile. This will ensure Bundler uses an older version of omniauth. However, that may cause conflicts with other gems, leaving you with the same problem - indeed, it's probably the reason Bundler didn't automatically try to install an older version.
Update your Ruby version. If you have a .ruby-version file in your application, update the version there to 2.1.9. Similarly if your Gemfile has a ruby "..." line in it, update that too. You'll probably also need to install the new version of Ruby locally - with rbenv you can use $ rbenv install 2.1.9, or if you use RVM try $rvm install 2.1.9.
My recommendation would be option 2 (updating your Ruby version).

Two versions of rspec installed on my computer?

I've been attempting to make a start on learning Ruby/rspec. I read that rspec is now broken for Windows so an early version (2.14.1) should be installed instead. I started on testfirst's learn Ruby but kept getting errors whenever I attempted the "rake" task. I checked my rspec version and apparently I'm running 2.14.8. I thought maybe that was why I was getting some errors. So I typed into git "gem uninstall rspec" but it then said version 2.14.1 was uninstalled, not .8. So I checked to see if there were any versions of rspec installed on my computer and it says that 2.14.8 is still installed... now it won't let me uninstall it, even though I typed in "gem uninstall rspec -v 2.14.8."
I also tried to check the contents of version 2.14.8, but it couldn't find gem 'rspec' in default gem paths.
It's as if I had two versions of rpec on my laptop... how do I get rid of the .8 version?
If gem uninstall rspec -v 2.14.8 did not work for you. Try cleaning up all the rspec version from your computer first by running:
gem cleanup rspec
Then, install the required version again.
Update:
Try:
gem uninstall -Iax rspec
If doesn't work, then try and remove the executables as well:
gem uninstall rspec-core
Where did you hear that RSpec is broken on Windows? AFAIK the current version (3.3.2) works just fine.
If you are going to learn Ruby and RSpec, you should also learn about using Rubygems and Bundler, since many projects rely on them. Install Bundler with:
gem install bundler
Create a new folder and CD into it, and then:
bundle init
This creates a file named "Gemfile" in the folder. This allows Bundler to manage the versions of gems used within your project. Edit the Gemfile and add this line:
gem 'rspec', '~> 3'
This tells Bundler that your project requires RSpec 3, and to install the latest version. Save the Gemfile, and then do:
bundle install
Bundler will install the RSpec gems and create a Gemfile.lock file that details the gem dependencies. To verify that the right version is installed:
rspec --version # => 3.3.2 (or whatever is the latest)

Rails gem update not working (version 4.1.1 to 4.2.0) as a solution to "warning: circular argument reference" error

I keep getting the following error when I run any sort of rake command, and in particular rake db:seed which will abort without completing:
$ rake db:seed
/Users/rachel/.rvm/gems/ruby-2.2.0#rails4.2/gems/activesupport-4.1.1/lib/active_support/values/time_zone.rb:285: warning: circular argument reference - now
rake aborted!
ActiveRecord::UnknownAttributeError: unknown attribute: description
I did some research and discovered this is an error (I think?) caused by an incompatible gem in Rails 4.1.9 so I was hoping to create a new rvm to update Rails to 4.2.0 so I can proceed with my projects. However, every time I try to update Rails it says 'installed' but fails to actually install into the ruby version I created. Here's the typical command line pattern when I try to update Rails:
$ rvm gemset create rails420
ruby-2.2.0 - #gemset created /Users/rachel/.rvm/gems/ruby-2.2.0#rails420
ruby-2.2.0 - #generating rails420 wrappers........
$ rvm 2.2.0#rails420
$ gem install rails -v 4.2.0
Fetching: rails-4.2.0.gem (100%)
Successfully installed rails-4.2.0
Parsing documentation for rails-4.2.0
Installing ri documentation for rails-4.2.0
Done installing documentation for rails after 339 seconds
1 gem installed
$ rvm 2.2.0#rails420
$ rails --version
Rails 4.1.1
Basically, it installs Rails 4.2.0 but then says it's not installed when I check the version immediately after installation. Any ideas for how I can either solve the error or get the Rails gem to update correctly in my rvm?
The issue causing the "warning: circular argument reference" was that the files in my project's Gemfile.lock didn't match the versions I was installing so it kept reverting to an out-of-date version and causing an error.
To fix, I updated all my gemsets and ran cleanup to make sure there were no out of date versions remaining, then ran the following commands:
rvm use --create 2.2.0#newtest
gem install rails
Fetching: rails-4.2.0.gem (100%)
Successfully installed rails-4.2.0
Parsing documentation for rails-4.2.0
Installing ri documentation for rails-4.2.0
Done installing documentation for rails after 326 seconds
1 gem installed
$ bundle install
I then checked the version to make sure that activerecord, activesupport, rails, and railties all had at least 4.2.0. Once I was sure those gems were working I created a new Rails project in the new updated rvm:
$ rvm use ruby-2.2.0#newtest
$rails new projectname
This created a new project with Rails 4.2.0 which is compatible with the right gems to avoid the "warning: circular argument reference" error, so I am no longer seeing it when I use rake or any other command. For a more detailed explanation see api.rubyonrails.org/classes/Rails/Railtie.html - Railtie is the gem that coordinates Rails actions like rake, so if it is out of date in your Gemfile.lock but not in your Ruby rvm it will create the error.
Try the following :
rvm use ruby-2.2.0#rails4.2 --create
gem install rails
rails -v
This should give you rails 4.2
This has now been resolved.
http://weblog.rubyonrails.org/2015/6/16/Rails-3-2-22-4-1-11-and-4-2-2-have-been-released-and-more/
fix ruby 2.2 warning: circular argument reference
https://github.com/rails/rails/commit/8fd52705eda6a2cd7e9a8a5bc723fa094e359eb7
use self.method syntax to resolve circular argument issues
https://github.com/rails/rails/commit/3a30b12c774dfaa72acfe520e823374131631ea9

rails version not found, even though it's available in the rubygems

I wanted to switch from Rails 4.1.1 to Rails 3.2, because I heard some specific features I am interested in work best in 3.2.
gem install --http-proxy http://web-proxy:8088 rails –v '3.2.18' --no-rdoc --no-ri - this command didn't work, no such version (3.2.18) is available so rails 4.1.1 (most recent version) was (re)installed automatically.
Here is the reason:
Fetching: rails-4.1.1.gem (100%)
Successfully installed rails-4.1.1
ERROR: Could not find a valid gem 'ûv' (>= 0) in any repository
ERROR: Could not find a valid gem '3.2.18' (>= 0) in any repository
1 gem installed
So: I go to rubygems.org, check list of available rails versions and I see that 3.2.18 (https://rubygems.org/gems/rails/versions/3.2.18) is actually an available version. What am I doing wrong. Why is 3.2.18 not found, if it's on the rubygems site?
I really need Rails 3.2 to have an issue fixed that works poorer in newer Rails versions (according to research in the internet) - many thanks in advance
It seems like you copied and pasted parts of your command resulting to non ASCII characters.
In particular, the dash (-) seems to be the issue here. Try again with this:
gem install --http-proxy http://web-proxy:8088 rails -v '3.2.18' --no-rdoc --no-ri
The error message partly gives it away (at least it points to encoding issues) in Could not find a valid gem 'ûv' (>= 0).
First you uninstall latest rails version in your gem. Then install rails 3.2 in your local system and bundle it in your project terminal. And then edit in your gem file as
gem 'rails','~3.2'
now restart server and run it

Why it's so slow to use `rails new`?

The version is:
bash-3.2$ rails -v
Rails 3.2.9
And my ruby is the built-in ruby on MacOSX:
bash-3.2$ ruby -v
ruby 1.8.7 (2012-02-08 patchlevel 358) [universal-darwin12.0]
bash-3.2$ which ruby
/usr/bin/ruby
My problem is that in the last step of rails new ( run bundle install), it seems that rails need to connect the internet to download some packages. And usually I need 5 minutes just wait for rails to create any project using rails new.
I was wondering whether somethings is not configured well for rails on my computer.
Another strange thing is that after I finished rails new PROJECT_NAME, it shows:
Using sqlite3 (1.3.6)
Using uglifier (1.3.0)
Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed.
It seems that sqlite3 has already been installed, however, when I try:
bash-3.2$ bundle show sqlite3
Could not locate Gemfile
It still complains that sqlite3is not installed. Maybe that's the reason that rails new is slow (Even sqlite3 has been installed once. It still needs to download the bundle)
Before bundle install, rails asks for my system password:
Enter your password to install the bundled RubyGems to your system
But I'm still not sure whether these packages have been installed into system, as bundle show sqlite3 failed.
Does anyone have ideas about why rails new is so slow on my computer? Thanks!
Another solution is to use RVM. It is similar to rbenv. I personally use RVM. I don't and would not recommend using the gemsets. Bundler does the separation of gem versions anyway.
Check what is up with your bundle install i.e. the last step in the rails new sequence. Run this instead:
rails new appname -B
The -B flag tells rails to "skip bundle" (reference). Then go into the app folder to run:
bundle install --verbose
Check for potential errors in the output.
Using different bundler versions can give you different results. So try other versions.
gem uninstall bundler -v your-version-number
gem install bundler -v new-version-number
In 2016, we got bundler v1.12.x which is causing some users to experience slow bundle install issues. In this case, using 1.11.2 is the faster option until they fix it.

Resources