Rails app -- can't deploy using CLI

ltrubov
FREE

a year ago

Deploying by linking up a Github repo worked fine. However, I'd also like to be able to deploy manually using rails CLI from my local machine. But all my attempts failed:

[Region: us-west1]
==============
Using Nixpacks
==============
context: 83b380b0b70679785532cdc51daf3348
Nixpacks build failed


Nixpacks was unable to generate a build plan for this app.
Please check the documentation for supported languages: https://nixpacks.com

The contents of the app directory are:

The local output of the command (verbose):

Indexed                                                                                                                                                                              Compressed [====================] 100%                                                                                                                                             railway up
service: ad5d9a79-e910-4403-9ec0-b38a599dcf74
environment: 2e368c38-36cb-4799-b43e-693319bb337a
bytes: 94
url: https://backboard.railway.app/project/37f0dd56-c65b-4b53-bf35-79fdf1284a27/environment/2e368c38-36cb-4799-b43e-693319bb337a/up?serviceId=ad5d9a79-e910-4403-9ec0-b38a599dcf74
  Uploaded
  Build Logs: https://railway.app/project/37f0dd56-c65b-4b53-bf35-79fdf1284a27/service/ad5d9a79-e910-4403-9ec0-b38a599dcf74?id=38d19b07-45f0-4aa6-b429-92e7d16e9aa5&

***BUILD LOG (SEE ABOVE) *** 

It looks like the process only uploaded 94 bytes, and obviously that has no content to build the app. There's clearly some basic mistake I'm making, given that:

  • The app has been successfully deployed to railway via a linked github repo (without changing the root directory in the settings)

  • Running nixpacks build . --name random-name creates a valid build without further configuration on my part

So what do I need to do?

View Deploy details

ⓘ Deployment information is only viewable by project members and Railway employees.

18 Replies

ltrubov
FREE

a year ago

Update: the error happens when I use the CLI on MacOS. Works fine on Linux. Applies whether I login or use a token, or whether I deploy in detached mode. CLI on MacOS does not upload the right content to deploy.

Is this supposed to happen, or is there a way to deploy from MacOS?


a year ago

Are you sure you are running railway up in the correct folder?


ltrubov
FREE

a year ago

Yes, I'm sure -- especially since, as I said, doing the exact same thing on Linux works correctly.


a year ago

Is your project on our mac on an external drive?

What version of the CLI are you using?


ltrubov
FREE

a year ago

No, on the main drive -- and I've actually attempted it on two different Macs, one Intel and one Apple Silicon, with the same results. I'm using version 3.12.1.


a year ago

What version of macos?


ltrubov
FREE

a year ago

14.6.1


a year ago

Do you see the same behavior with all projects?


ltrubov
FREE

a year ago

Haven't attempted with another project.


a year ago

Let me know how that goes please.


ltrubov
FREE

a year ago

Same problem: I ran the commands below and got the exact same output, with a failure to build nixpaks and empty app directory contents.

 3030  railway init -n experimental-railway-project
 3036  rails new experimental-railway-project
 3038  cd experimental-railway-project
 3049  rails server # check that it will run locally
 # Here I created an empty service manually in the web portal
 3054  railway link
 3058  railway status # check link
 3067  railway up

Link to the failed build here:

https://railway.app/project/6bef699c-92ad-4e60-8dd7-34ebdbe4d127/service/d3690d57-2582-4635-bef7-e456f6ea2ce4?id=662f1654-359e-4039-bf99-8e1f39c0d2f2

Meanwhile on Linux:

rails new experimental-railway-project
cd experimental-railway-project
railway link
> Select a project experimental-railway-project
> Select an environment production
> Select a service stellar-elegance
alpine-vm:~/work/experimental-railway-project$ railway up
  Indexed
  Compressed [====================] 100%
  Uploaded                                                                                                                            Build Logs: https://railway.app/project/6bef699c-92ad-4e60-8dd7-34ebdbe4d127/service/d3690d57-2582-4635-bef7-e456f6ea2ce4?id=3bd49367-6cb5-4cf6-91bc-f07711de964e&

[Region: us-west1]
=========================
Using Detected Dockerfile
=========================

context: 9906c44c2d0de246b13d86b81e12085e
#0 building with "default" instance using docker driver

{{ FURTHER OUTPUT TRUNCATED }}

Now, that plain project didn't actually deploy because I didn't setup the variables for the production environment, but it did upload and build, which the attempt on the Mac hadn't.


a year ago

Hmmm, not really sure what to tell you here, this seems like it's an issue with macos.


ltrubov
FREE

a year ago

Update 2: It's something specifically with my setup. I ran a deploy through a GitHub action on a MacOS runner, and it succeeded (deployment ID `df668386-7b61-42a5-922e-bc8a0e383db0`)


ltrubov
FREE

a year ago

Mystery solved!

This is indeed due to my setup (though it's not that unusual). I keep a git repo in my home directory to manage various config files, and since I don't want to put everything into that repo, I only explicitly add specific files using the -f flag, and I have this:

√  work git:(personal) cat ~/.gitignore
*
√  work git:(personal)

I use an alternate file to actually manage the global ignores, and set that in .gitconfig.

Now it makes sense. Railway looked up what to ignore via .gitignore , but rather than using just the project's own .gitignore, it used the combination of that plus the system's -- which says to ignore everything! So it did.

When I renamed that global .gitignore file, railway up ran correctly.

Should I file an issue on the project's GitHub? Intuitively, this behavior seems incorrect to me -- when uploading the project, a tool like Railway should consider the project's own .gitignore, but not the system's global one, which likely has nothing to do with the project and may for some parameters be overridden by it.


a year ago

I'm glad you figured it out but this wouldn't be an issue with the CLI itself so there wouldn't be anything we can do, it would be an issue with WalkBuilder - https://docs.rs/ignore/latest/ignore/struct.WalkBuilder.html

And looks like someone already has the same issue - https://github.com/BurntSushi/ripgrep/issues/1394


ltrubov
FREE

a year ago

Not quite. Since `WalkBuilder` is part of the ripgrep project , I've downloaded ripgrep, and here's what I found:

backend git:(railway) rg controller
config/initializers/wrap_parameters.rb
7:ActiveSupport.on_load(:action_controller) do

config/application.rb
8:require 'action_controller/railtie'

config/environments/test.rb
23:  config.action_controller.perform_caching = false
29:  config.action_controller.allow_forgery_protection = false

config/environments/development.rb
17:    config.action_controller.perform_caching = true
24:    config.action_controller.perform_caching = false

config/environments/production.rb
15:  config.action_controller.perform_caching = true
27:  # config.action_controller.asset_host = 'http://assets.example.com'

app/controllers/authentication_controller.rb
1:# app/controllers/authentication_controller.rb
√  backend git:(railway) cd ~
√  ~ git:(personal) rg controller
rg: No files were searched, which means ripgrep probably applied a filter you didn't expect.
Running with --debug will show why files are being skipped.
✗  ~ git:(personal)

So yes, it will (possibly incorrectly) read in the ~/.gitignore file when there's no alternative, even though it's not the actual ignore file used by git, but when run from within a directory with its own .gitignore, it'll only use that.

Does the railway CLI switch to the home directory internally before attempting to upload?



ltrubov
FREE

a year ago

Is there a way to get the contents of the uploaded directory for a successful build, the way I've been getting printouts for failed ones? If it includes .bundle, log, node_modules, etc. we'll know that the .gitignore file the CLI tool used was the (for that build, nonexistent) global one rather than the one inside the project.