So I am trying to deploy a Rails app on my web hosting service. I have developed an app locally, but this is the first time I have tried to get it to work on another server. My service provider is Blue Host and I am on their most basic shared hosting plan. Just as a test, I created a fresh application on the server, and everything ran fine. However, whenever I add any gem to the Gemfile and run 'bundle install', I get this error:
sudo: unable to stat /etc/sudoers: No such file or directory
sudo: no valid sudoers sources found, quitting
sudo: unable to initialize policy plugin
Gem::Exception: Cannot load gem at [/usr/lib64/ruby/gems/1.9.3/cache/rake-10.4.2.gem] in /home/user/application
An error occurred while installing rake (10.4.2), and Bundler cannot continue.
Make sure that `gem install rake -v '10.4.2'` succeeds before bundling.
Whenever I run gem install rake -v '10.4.2' the gem installs fine.
I get similar errors that mention 'sudo' when i try to run other commands as well.
I am not quite sure what this error means. Do I not have the required permissions on my server?
Always use a continuous deployment/integration.
Capistrano does part of the job. It is very simple, you develop you application offline, push to a remote repository, like BitBucket or Github, and then Capistrano takes care of cloning the remote repository to your server (you can also have many), restarting services etc.
If you want to go a step forward you can use continuous integration, so when you push to remote tests will automatically be performed and if they pass your application will be deployed.
This is a basic introduction on how deployment works, you can check online, there are plenty of resources about how to deploy rails.
Go with root user
su root
root$ /etc/
Related
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.
I have a working rails application deployed to EC2 through ElasticBeanstalk. I update the website every few weeks without issue. Today I'm running into a problem after committing changes and running "eb deploy":
An error occurred while installing nokogiri (1.7.0.1), and Bundler cannot
continue.
Make sure that `gem install nokogiri -v '1.7.0.1'` succeeds before bundling.
I haven't changed anything aside from a few views. The host is the same and the Gemfile is the same. On my local machine, I can run that command and then bundle install/update without issue. I can SSH to the EC2 host and successfully run that command to install that version of Nokogiri, too.
When I deploy, I get that error message (with no other details). I'm stuck - Any idea what I should look into next? Note that this started happening to a working setup, so I don't think it's the host missing libxml or another dependency.
Found it. There was a line in the log file that I was missing.
"Cannot allocate memory"
Rails was using a lot more memory than I thought. Just sitting there it was using 1.7GB out of 2.0GB. I temporarily added 1GB of swap and the deployment succeeded.
I have a Windows 2012 server that is on an internal network. I used Railsinstaller to put the basic framework on the system. Rails new doesn't work when I reach the bundler section since I can't reach the net.
I have used "gem install rails -i repo --no-rdoc --no-ri" on a net accessible system then placed the gems on my server and ran "gem install --force --local *.gem".
Then "rails new D:\DTS_WEB --edge" and now fail at "unable to connect to github.com". Trying to start the rails server fails telling me that nothing has been checked out.
I modified my gems file with
"gem 'rails', path: '....\Ruby2.2.0\lib\ruby\gems\'" but it still tries github.
I installed git with Railsinstaller along with rails. How can I get past this last obstacle and force everything to use local resources?
Is it possible to build everything on the net accessible node and just copy it into place on the server to use? My first attempt at that failed.
On a machine that has a network connection, you can install your app's gems to a directory within the project using --path:
$ bundle install --path=vendor/bundle
Then, you can copy the project folder (along with all the gems in vendor/bundle) to your internal machine.
I'm attempting to deploy a Rails app which I have developed on Windows, to Openshift. However, the bundle is not complete, because Gemfile.lock contains lines like:
pg (0.17.0-x86-mingw32)
which therefore don't get installed on the Linux instance at Openshift.
Knowing that Heroku works around this by detecting a Windows Gemfile.lock and removing it, I have tried adding a `.openshift/action_hooks/pre_build script doing either
rm Gemfile.lock
or
sed -i /mingw32/d Gemfile.lock
But neither helps. How can I deploy my app to Openshift and have it pick up suitable Linux versions of all gems?
Try including a full path to the file, like this: rm $OPENSHIFT_REPO_DIR/Gemfile.lock
You should be able to connect to the server via rhc ssh in order to test the solution.
I'm building a rails app using gitlab ci and a few issues came up.
The first was it couldn't find rake to run the tests
I installed rake on my digital ocean manually to solve this
Then it was complaining the gitlab_ci_runner is not in the sudoers list
I added gitlab ci to the sudoers list which solved that problem
Now when running bundle install it is complaining that Bundler::GemspecError: Could not read gem for every single gem unless I install them myself.
Am I missing something with the way I setup gitlab ci?
Try using the 'gitlab_ci_runner' w/o switching user.
sudo -u gitlab_ci_runner -H bundle install --deployment
If you're root user that has a password (meaning your NOT using a SSH-Key) use this to switch back to root user.
su