2 months ago
I have a pretty standard Rails app. The Ruby version is defined in .ruby-version and the Gemfile references this using the syntax:
ruby file: '.ruby-version'When attempting to deploy to Railway, I get the following error after Railpack 0.15.4 runs bundle install:/usr/local/bundle/gems/bundler-2.7.2/lib/bundler.rb:524:in 'File#initialize': No such file or directory @ rb_sysopen - /app/.ruby-version (Errno::ENOENT)
Railway doesn't think that .ruby-version exists for some reason. This app is currently deployed to Heroku and is running without a problem there, so it's definitely not an issue with the code or the location of the file, but some difference in the build process. I can see explicit references to copying over the Gemfile before this, so my best guess is that Railway has not copied over the .ruby-version file at this stage and is therefore erroring.
The Railpack guidance for Ruby (https://railpack.com/languages/ruby) says that
If your Gemfile includes gems with local
path:specifications, Railpack will automatically copy those local directories during the build process.
and this feels like it's essentially the same problem and just hasn't been implemented for file:.
1 Replies
2 months ago
the most reliable way to fix this is to specify the Ruby version directly as a string.
i mean, Railpack will still detect your .ruby-version file to decide which Ruby version to install on the server, but Bundler won't crash looking for a file that isn't there during the build step.
so you ought to change your Gemfile from:
ruby file: '.ruby-version'
To:
ruby '3.3.0' # here is where you put your specific version