Rails Version Resolving Issue - ruby-on-rails

The root cause of my problem is that json 1.8.3 won't install. The original version of rails in my gem file was 4.1.14. I changed it to 4.1.16 and ran bundle update. json 1.8.6 was then installed locally.
However, when I deploy to Heroku, it still resolves the rails version to 4.1.16 and tries installing json 1.8.3 (which fails).
What can I do to resolve this issue and be able to successfully deploy my app?

The gem version should never resolve differently. That's the whole purpose of the Gemfile.lock.
Ensure that you have committed and pushed any changes to the Gemfile.lock.
If the file is not in source control (e.g. if you've added it to .gitignore?), then don't do that -- the file should be in source control.

Related

Bundler 2, Gemfile not found error when running any rails or rake command

I am setting a new app, stack is:
ruby: 2.6.1 (using rvm)
rails: 5.2.2
bundler: 2.0.1
Now thing is, bundler 2 doesn't use Gemfile at all, i have proper gems.rb and gems.locked and everything was working properly until i pulled some code from a co-worker which got merged.
Issue is whenever i run any rake or rails command i get this error:
/path/to/proj/Gemfile not found
I then even tried going back to old master when that code was not merged and issue is still there. So it is probably not something in the code i pulled.
And issue seems persistent in different machines.
I know there are other issues which have similar errors of Gemfile not found but those are mostly those which had wrong directory opened or some gem issued fixed by bundle update or gem update type commands, this is not that issue because. This is something else, because bundler 2 doesn't even need Gemfile.
It looks like rails doesn't support using gems.rb and gems.locked. https://github.com/rails/rails/issues/31295
You could try what that guy did and edit some files, or you could rename your gems.rb back to Gemfile and gems.locked back to Gemfile.lock

Rails bundle error when pushing to Elastic Beanstalk

I had an app deployed on Heroku and I am currently trying to create the same app on AWS.
I've copied my folder, created a complete separated repo on Github and installed ebcli, the setup looks fine.
When I try to run eb deploy, I have this error:
[Instance: i-03051e2a022886184] Command failed on instance. Return code: 1 Output: (TRUNCATED)...:in find_spec_for_exe': can't find gem bundler (>= 0.a) with executable bundle (Gem::GemNotFoundException)
from /opt/rubies/ruby-2.5.3/lib/ruby/site_ruby/2.5.0/rubygems.rb:308:inactivate_bin_path'
from /opt/rubies/ruby-2.5.3/bin/bundle:23:in `'.
I've looked online and it says it comes from incompatibility between your gemlock file bundler version and actual bundler version.
I've tried to change my bundler version to this one, but I gave up and came back to 2.0.1 because I had to install too many dependencies otherwise.
I removed the gemlock, bundle again, but I still got the same error when trying to deploy.
With my heroku version, it always worked.
Any idea how to solve that?
Thanks a lot
We moved from Heroku to AWS a few months back as well and it will likely take some some custom scripting to get things to work.
It would help to know more about your EB environment, but I am assuming you are using Ruby 2.5 with Puma on Amazon Linux 2.9.0 (?)
Not sure what bundle version comes with that, But I don’t think it’s 2.x. so you have to add an .ebextensions file too install your preferred bundled version.
# .ebextensions/01_install_bundler.config
container_commands:
install_bundler:
command: “gem install bundler —-version 2.0.0”
More info on AWS Linux customizations
End of the day, we are much happier with our AWS environment (lower cost, better performance), but requires more work to get it set up
Actually the problem exists because the bundler version in the eb env is older than the one being used in the project source.
So the solution is to use a bundler version less or equal the eb env installed version.
First uninstalled the current bundler:
gem uninstall bundle
and then install the desired one:
gem install bundler -v 1.16.6
See more details

Ruby On Rails Heroku APP

I am working on Ruby On Rails Shopify App deployed on Heroku. Suddenly error occured "uninitialized class variable ##storage in ShopifySessionRepository". I was unable to trace this.I rollback the code to previously deployed code and app worked. But now, the code which i have is with errors. So i cannot push any more code to heroku. And i cant even access the code which is working(previous code). I dont how to get out of this situation now. I am new to git, heroku and ruby on rails.Is there any way, i can access the working code using git or anything else. If not, what this error message is "uninitialized class variable ##storage in ShopifySessionRepository" and why it occurred?
I am using rails 4.0.2
This issue occurred because the the version of the shopify gem was automatically upgraded while pushing the code to heroku. Because no version was specified in the gem file for this gem, it was upgraded. The file ShopifySessionRepository was not present in the earlier version of the gem file. This was added in the latest version.
I added the older version of the gem in the gem file like this
gem 'shopify_app','~> 4.4.4'
and it worked. Now i don't know that my code was not compatible with the latest version of the gem or there is any bug in the latest version. But degrading the version solved the issue.
The bug is fixed in the current version of the shopify_app gem, 5.0.0

Bundler and Heroku with offline gems

I'm running a Rails 3.2 app that depends on an offline gem, chilkat. (http://www.chilkatsoft.com/ruby.asp).
I've gotten this to work on my development environment by doing the following:
Unpacking the gem into my vendor/gems folder
Adding this line to my Gemfile
gem 'chilkat', '9.4.1', path: 'vendor/gems/chilkat-9.4.1-universal-darwin-12', require: false
(These steps were taken from How to use Bundler with offline .gem file?)
BUT when I push the code to Heroku, the app crashes with the error:
/app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.14/lib/active_support/dependencies.rb:317:in `rescue in depend_on': No such file to load -- chilkat (LoadError)
Do you know what I need to do to get the gem installed properly on Heroku? Thanks!
Ok I figured out the issue. The Chilkat gem I'm using has OS-specific versions, and the version I unbundled in vendor/gems is for OSx won't work on Heroku/AWS. So even if the path would have worked correctly in Heroku, the gem itself would not.
The problem I face now is because the Chilkat gem is OS-specific, Bundler will generate a Gemfile.lock file specific to the OS on which bundle install was called (OSx in my case). That OSx-specific Gemfile.lock is incompatible with AWS's machines, so Heroku complains that I can't push the code since the Gemfile.lock is inconsistent with what is expected.
This appears to be a known issue with Bundler (How to add Mac-specific gems to bundle on Mac but not on Linux?). I could just avoid committing Gemfile.lock, but we rely on the version dependency management that Gemfile.lock provides. And I don't want to get all the developers on my team to switch to developing on Linux/Unix. Anyway that's a separate issue so I'm closing this for now. Thanks to the people who commented!

Passenger error

I'm getting this error with Passenger:
https://github.com/huerlisi/PDFKit.git (at master) is not checked out. Please run `bundle install` (Bundler::GitError)
When I run cap deploy (I'm using capistrano), it's saying that it's bundling the gem, so I'm not sure what's wrong.
I'm the huerlisi who's PDFKit branch you're using. I just want to tell you that you should consider switching back to the original branch at https://github.com/jdpace/PDFKit as I'm not maintaining my branch, and the 'always render as PDF' bug has finally being fixed:-)
If you're installing gems from a git source, you will need to install them using bundle install as the error says. The contents of them are usually saved in ~/.bundler and loaded in from there according to the specific version saved in Gemfile.lock.
What could be happening is that your application does not have a valid Gemfile.lock to latch on to and uses system gems by default.
What does bundle check show on your installed app?
It is not uncommon to have gems installed for the wrong version of ruby if you're using something like rvm.

Resources