Various difficulties creating Rails apps in different versions and installing Spree - ruby-on-rails

As per rbenv -global my ruby version is 2.3.3
The versions of Rails I have:
*** LOCAL GEMS ***
rails (5.1.1, 5.0.0)
Initially, my goal was to create a Rails with Spree. Like usual I began with:
rails new spree_app
Following the Spree README I then added the following gems to my gemfile:
gem 'spree', '~> 3.2.0'
gem 'spree_auth_devise', '~> 3.2.0.beta'
gem 'spree_gateway', '~> 3.2.0.beta'
Then, when I ran bundle install I'm met with the following errors:
Bundler could not find compatible versions for gem "rails":
In snapshot (Gemfile.lock):
rails (= 5.1.1)
In Gemfile:
rails (~> 5.1.1)
spree (~> 3.2.0) was resolved to 3.2.0, which depends on
spree_frontend (= 3.2.0) was resolved to 3.2.0, which depends on
canonical-rails (~> 0.1.0) was resolved to 0.1.2, which depends on
rails (< 5.1, >= 4.1)
spree (~> 3.2.0) was resolved to 3.2.0, which depends on
spree_core (= 3.2.0) was resolved to 3.2.0, which depends on
deface (~> 1.0) was resolved to 1.2.0, which depends on
rails (>= 4.1)
spree (~> 3.2.0) was resolved to 3.2.0, which depends on
spree_core (= 3.2.0) was resolved to 3.2.0, which depends on
rails (~> 5.0.0)
Running `bundle update` will rebuild your snapshot from scratch, using only
the gems in your Gemfile, which may resolve the conflict.
Running bundle update as suggested yields me this:
Bundler could not find compatible versions for gem "rails":
In Gemfile:
rails (~> 5.1.1)
spree (~> 3.2.0) was resolved to 3.2.0, which depends on
spree_core (= 3.2.0) was resolved to 3.2.0, which depends on
rails (~> 5.0.0)
So it seems to me that Spree depends on Rails 5.0.0 and my 5.1.1 is causing problems. In light of this I changed gem 'rails', '~> 5.1.1' to gem 'rails', '~> 5.0.0', ran bundle update and bundle install and everything worked properly bundler-wise.
The issue is that this seems to have broken my rails app. Running, any rails generate commands or rails s gives me the following error:
/usr/local/opt/rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/railties-5.0.3/lib/rails/railtie/configuration.rb:95:in `method_missing': undefined method `load_defaults' for #<Rails::Application::Configuration:0x0055a1cd5a36f0> (NoMethodError)
For the life of me, I have no idea what is the matter here.
My final attempt was to try and generate a new Rails app in 5.0.0 with:
rails _5.0.0_ new spree_app_2
But for whatever reason, this seems to make no difference. The gemfile of this app still contains gem 'rails', '~> 5.1.1' and I am met with all the same errors that I got before hand.
So it seems that I either, don't know how to manage different versions of Rails, I'm not installing Spree correctly, or both. Any help is appreciated, thanks.
Update: Partial Solution
I still don't know how to generate a Rails app in any version other than 5.1.1, and simply changing the version in the gemfile still doesn't work for me. It seems to me that some other changes are need.
I switched the version of rails in the gemfile from 5.1.1 to 5.0.3. looked at the /config/application.rb files from Rails apps using 5.0.2 and found that they had a different setup.
Mine looked had this:
module AppName
class Application < Rails::Application
config.load_defaults 5.1
end
end
And the rails app generated in 5.0.2 had like this:
module AppName
class Application < Rails::Application
config.generators do |generate|
generate.assets false
end
end
end
So I swapped out what I had with that and it worked! I don't really know why it worked and I still don't know why I can just generate a 5.0.3 Rails app from the get go.

I am by no means a Spree expert, but from what it looks like, 5.1.1 is not compatible with Spree.
spree (~> 3.2.0) was resolved to 3.2.0, which depends on
spree_frontend (= 3.2.0) was resolved to 3.2.0, which depends on
canonical-rails (~> 0.1.0) was resolved to 0.1.2, which depends on
rails (< 5.1, >= 4.1)
In your Gemfile, go ahead and put gem 'rails', '5.0.3' at the top (replacing any other rails gems), then rm Gemfile.lock followed by a bundle
Should do the trick.

Related

updating rails 4.2.5 to rails 5, keep having ActiveModel dependencies issues

when updating a rails 4.2.5 app (thats in production on heroku) to rails 5, i keep running into the below incompatible version for the gem, i've tried the bundle update, bundle install, done everything asked by the upgrade docs on rails site and stackoverflow.
Bundler could not find compatible versions for gem "activemodel":
In snapshot (Gemfile.lock):
activemodel (= 5.0.0)
In Gemfile:
active_model-errors_details was resolved to 1.3.0, which depends
on
activemodel (< 5.0.0.beta1, >= 3.2.13)
carrierwave was resolved to 1.2.2, which depends on
activemodel (>= 4.0.0)
rails (= 5.0.0) was resolved to 5.0.0, which depends on
activemodel (= 5.0.0)
web-console (~> 2.0) was resolved to 2.3.0, which depends on
activemodel (>= 4.0)
Running `bundle update` will rebuild your snapshot from scratch,
using only
the gems in your Gemfile, which may resolve the conflict.
There is no version of the active_model-errors_details that supports Ruby on Rails 5.x (see its Rubygems page).
But the documentation of the active_model-errors_details says that it is a feature backported from Rails 5.0 to use with Rails 3.2.x and 4.x apps.
Therefore I think there is no need to keep that gem in your application once you update to Ruby 5.0. Just remove the gem 'active_model-errors_details' line from your Gemfile and run bundle install again.

Ruby on Rails: Gem Dependency Issues

I am trying to install the most recent version of haml, simple_form, and devise to my Ruby on Rails application, but I cannot seem to get them working with the Bundler tool. How should I proceed in order to get past the dependency issues?
This is the error raised by the Bundler tool:
Bundler could not find compatible versions for gem "activemodel":
In snapshot (Gemfile.lock):
activemodel (= 5.1.1)
In Gemfile:
rails (~> 5.1.1) was resolved to 5.1.1, which depends on
activemodel (= 5.1.1)
rails (~> 5.1.1) was resolved to 5.1.1, which depends on
activemodel (= 5.1.1)
simple_form (~> 3.4) was resolved to 3.4.0, which depends on
activemodel (< 5.1, > 4)
web-console (>= 3.3.0) was resolved to 3.5.1, which depends on
activemodel (>= 5.0)
Unfortunately, simple_form is not compatible yet with Rails 5.1 as you can see from this commit https://github.com/plataformatec/simple_form/commit/8d15b7ebc8096348b611e9f2905a2576a5bce508
You'll either have to wait for a new version of simple_form or use an earlier version.
Run bundle update with --conservative key, it does not try to update rails dependencies, these gems have.
bundle update haml simple_form devise --conservative
If you may, try using rails version 4.2.4
This will allow you to use 'simple_form' and 'nested_form' if needed.

How to install spree_static_content?

How do I install spree_static_content? I get following error.
In Gemfile:
spree_core (~> 3.0.0) ruby
spree_core (~> 3.0.0) ruby
spree_core (~> 3.0) ruby
spree_static_content (>= 0) ruby depends on
spree_core (~> 3.1.0.beta) ruby
spree_core (= 3.0.1) ruby
spree_core (= 3.0.1) ruby
spree_core (= 3.0.1) ruby
spree_core (= 3.0.1) ruby
Could not find gem 'spree_core (~> 3.1.0.beta) ruby in any of the sources
At last it said that I need to do
bundle update
I did that but again get the same error.
The master branch of spree_static_content is, as if this writing, referencing 3.1.0.beta of Spree. Any project using an older version of Spree, like 3.0-stable, will not be compatible.
To use this gem for a 3.0-stable Spree project, you'll need to use the branch of spree_static_content that is built to run against that version of Spree. You can view it here:
https://github.com/spree-contrib/spree_static_content/tree/3-0-stable
Your Gemfile should use this line to include the gem:
gem 'spree_static_content', github: 'spree-contrib/spree_static_content', branch: '3-0-stable'
Note the branch: value. For other versions of Spree, find the matching branch of spree_static_content.
The error message tells you what to do.
The error is:
spree_static_content (>= 0) ruby depends on spree_core (~>
3.1.0.beta) ruby
That means you need spree_core 3.1.0.beta or higher.
Running bundle update will not update a gem beyond the version specified in the Gemfile.
It appears you may have the same gem listed multiple times in your Gemfile, as well.
Try adjusting your gemfile to have just one entry for spree, of the appropriate version. It will probably look like this:
gem 'spree', github: 'spree/spree'
Note that the spree documentation instructs adding spree, not spree_core. The spree gem will include the appropriate spree components of the correct version.
Please also not that updating spree is usually a little more involved than simply updating the version number and running bundle update. You will likely need to make other adjustments to your application to accommodate the new version.

Rails gem for adding an on site tutorial supported for rails 4

I'm attempting to add an on boarding tutorial to my site. I've installed the joyride-rails gem and am getting this error when running bundle install.
Bundler could not find compatible versions for gem "rails":
In Gemfile:
joyride-rails (~> 0.0.14) ruby depends on
rails (~> 3.1) ruby
rails (4.1.6)
I've done some research and found this answer Dependency error while installing the gem "joyride-rails"
And this answer Simple Javascript Joyride plugin in rails
The problem is I think that the joyride gem just isn't compatible with rails 4 and when I down grade to 3.1 a bunch of my other gems are in conflict. I delte the gemfile.lock and run bundle install and get this error.
Bundler could not find compatible versions for gem "railties":
In Gemfile:
coffee-rails (~> 4.0.0) ruby depends on
railties (< 5.0, >= 4.0.0.beta) ruby
rails (= 3.1) ruby depends on
railties (3.1.0)
Any suggestions as to how I can implement this gem? Or do you know of another Gem that will accomplish the same goal?
Thanks!

How to install Refinery CMS using Rails 4

I previously never had a problem with Refinery. I was refreshing my knowledge by following along to the tutorial http://railscasts.com/episodes/332-refinery-cms-basics .Then when I created a new app with Refinery CMS, I got this error
Bundler could not find compatible versions for gem "actionmailer":
In Gemfile:
refinerycms (~> 2.1.0) ruby depends on
actionmailer (< 3.3, >= 3.1.3) ruby
rails (= 4.0.0) ruby depends on
actionmailer (4.0.0)
But should not these things be there by default with the CMS? why would there be errors only now?
The latest code supports Rails 4; the gem must be sourced from the master branch, until a release is made.
Git Issue #2428 - Rails 4 support
Add to your Gemfile:
gem 'refinerycms-i18n', github: 'refinery/refinerycms-i18n', branch: 'master'
gem 'refinerycms', github: 'refinery/refinerycms', branch: "master"
# Strong parameters is a new feature not used by Refinery
gem 'protected_attributes'
Do a:
$ bundle install
Create a new Refinery app, the command will be different depending on what you want to do. For that there are a few guides that you can follow. In my case, I added it to an existing app with:
$ rails generate refinery:cms --fresh-installation
Start your server and go to: http://localhost:3000/refinery
Well, my five cents are that Refinery is not yet available for Rails 4:
Is there any cms for Rails 4?
http://refinerycms.com/
http://refinerycms.com/blog/refinery-cms-210-released
Best,
Ben.
Simply initialize the application using:
rails new my_new_application -m http://refinerycms.com/t/edge
Behind the scenes:
This command makes your application use the master branch of refinery, which supports Rails 4.
Update
Although the above is the easiest and official way, it didn't totally work for me. I had to manually run the following command after the above one:
rails generate refinery:cms --fresh-installation
Looks like the rails4 branch has been getting a bit of love over the past few days:
https://github.com/refinery/refinerycms/tree/rails4
I will try it out and update with how I get on.
OK, let's try and answer this one. This is the route I went down.
First, I installed the refinerycms gem.
gem install refinerycms
I then did a:
rbenv rehash
Then I followed the guide:
refinerycms rickrockstar
Bundler complained:
Bundler could not find compatible versions for gem "refinerycms-core":
In Gemfile:
refinerycms (~> 3.0) ruby depends on
refinerycms-images (= 3.0.0) ruby depends on
refinerycms-core (= 3.0.0) ruby
refinerycms (~> 3.0) ruby depends on
refinerycms-images (= 3.0.0) ruby depends on
refinerycms-core (= 3.0.0) ruby
refinerycms (~> 3.0) ruby depends on
refinerycms-images (= 3.0.0) ruby depends on
refinerycms-core (= 3.0.0) ruby
refinerycms (~> 3.0) ruby depends on
refinerycms-images (= 3.0.0) ruby depends on
refinerycms-core (= 3.0.0) ruby
refinerycms-wymeditor (>= 1.0.6, ~> 1.0) ruby depends on
refinerycms-core (>= 3.0.0, ~> 3.0) ruby
refinerycms-acts-as-indexed (>= 1.0.0, ~> 1.0) ruby depends on
refinerycms-core (~> 2.1.0) ruby
In my gemfile, I changed the following lines:
gem 'rails', '4.2.4'
gem 'refinerycms'
gem 'refinerycms-acts-as-indexed'
gem 'refinerycms-wymeditor'
And this solved the issue.
I had to then do a:
bundle install
Then a:
rails generate refinery:cms --fresh-installation
I posted an issue on github and got the following answer from the RefineryTeam:
It looks like the culprit was refinerycms-acts-as-indexed version - it should be ~> 2.0.1 to work with Refinery 3.0.0
https://github.com/refinery/refinerycms/issues/3072
Please also see this page where things might be running more smoothly than following the guide on Refinery's website. What is to be seen there is similar to Zuhaib Ali's answer above (in a bit more details).
Hope this helps

Resources