How to debug Rails' "cannot load such a file -- sprokets/railtie" message - ruby-on-rails

I have a webapp working perfectly fine locally, but when I come to start up the server in the production environment, I get this error:
"C:/RailsInstall/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/sass-rails=4.0.5/lib/sass/railtie.rb:1:in 'require': cannot load such a file -- sprockets/railtie (Load Error)"
What's gone wrong? How might I fix it?
If you need any other information, please let me know and I can update. "bundle install" runs fine, says that my bundle is complete.

I would suggest running bundle install prior to running the server in the production environment as that gem may not have been installed on the server. Also, a possible cause of the error could be if the sprockets gem is included in your Gemfile but is located inside a group that is not being loaded by Bundler because of using the --without parameter.

Related

cannot load such file -- pty (LoadError) Dev Environment Setup

I've been struggling to put together my dev environment while getting this error after I've had a clean bundle install with zero issues as well as checking that my rbenv is set up and my ruby version is set to the correct dev environment requirements. Whenever I try to boot up the rails server or console I am met with the error below.
/Users/devadmin/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/activesupport-6.0.3.7/lib/active_support/dependencies.rb:324:in `require`: cannot load such file -- pty (LoadError)
I have tried installing rubysl-pty to no avail as well as setting up the environment from scratch multiple times still getting this error. I am currently on a Mac using Big Sur I am not really sure where to begin with this issue as pty comes supported with Ruby but I have reinstalled it and rbenv multiple times to still get this error.
Sometimes I also see this kind of errors
You should try add RAILS_ENV=development to your command line, I hope it work.
Example
RAILS_ENV=development bundle exec rails s

How to fix "bundler: command not found: rails" when deploying using Google Cloud App Engine

I am trying to deploy my Rails app to Google Cloud using App Engine Flexible Environment. Everything works fine when I run gcloud app deploy, but at the very end, when App Engine tries to run my application using bundle exec rails server -p $PORT, as specified in my app.yaml file, it crashes and gives the following error message:
Error Response: [9] Application startup error: 'bundler: command not
found: rails Install missing gem executables with bundle install
I tried changing the entrypoint value, running bundle install again and again, and installing all my gem files locally, but none of that worked. I also tried installing rack and changing the endpoint to run the app using rackup command, but that didn't work either. I am also skipping my gemfile.lock in my app.yaml file due to a previous error that was solved on SO.
I think you'd also want to install bundler in your container instance.
gem install bundler
The reason I was getting this error is because I was skipping the Gemfile.lock due to a previous error that I thought was solved here. The aforementioned 'solution' led to this error. The solution that I found is to make some edits to Gemfile.lock that solved the issue instead of avoiding it. The edits can be seen here.

how do I add a gem in heroku?

I updated a gem(rtf) in my ruby on rails app through the Gemfile. The app works fine on my localhost but when I pushed changes to heroku and tried 'bundle install' within heroku bash. I see that the gem has been installed based on the log
Using rtf (0.3.3)
Following this, I did a
heroku restart --a myapp
however, when i tried the app on heroku, it still cant recognize the lib installed through the gem, i get the following error(normally appears when the library cannot be reached for command "require 'RTF'").
cannot load such file -- RTF
What am I doing wrong in heroku?
I think you misunderstand how Heroku works. When you run a bash shell on your app, nothing you do on that dyno will affect any other dynos for your app (like your web dynos). Heroku runs bundle install for you when you deploy your app and if your Gemfile is configured correctly all the gems will be installed.
the answer by sevenseacat is right- i had just got the case wrong-
require 'rtf'
works fine. In OSX, it ignores case in the command require 'RTF'

Rake 10.0.4 not found in sources

I've just pushed a new Rails app from my local development machine to a server I have that has a few Rails apps already on, bundle installs everything correctly and rake tasks run fine, however when I try and start the app it fails with that message.
I've:
Trashed my Gemfile.lock and reran bundle install
Done gem install rake to get the latest version
Checked rake --version shows 10.0.4.
Checked bundle show rake shows 10.0.4
Restarted the server
Now I'm drawing a blank on what it could be. Using Phusion Passenger, rails 3.2.13, ruby 1.9.2p290. I use rvm for managing the environment, but I've not changed anything with it for a long, long while now. The other Rails apps are all working okay without any issues, with similar gem dependencies.
Self fixed, but not sure why. I ran bundle install rake by accident, forgetting it doesn't do what I think and it created a ./rake folder which solved the issue.
Perhaps your application is being run as the wrong user.

Error while running rails on remote host. "Could not find crack-0.1.8 in any of the sources"

I am trying to deploy my rails app that is working fine on my local machine , to a remote host. I am using railsplayground.com to be exact. When I try to run the app using Passenger,I get this error
"Could not find crack-0.1.8 in any of the sources"
But when I did a,
$gem list
the gem , crack (0.1.8) is present. I am using Rails 3 btw.
Any suggestions is welcome. Thanks in advance.
Make sure the Gem is installed via Bundler. Check your Gemfile and see if the gem is listed.
Then, when deploying the application, make sure to execute the $ bundle install command.
If you deploy the project with capistrano, you can use the default bundler recipe by including the recipe at the top of your deploy.rb file.
require 'bundler/capistrano'

Resources