Deploying flyctl (fly cli) on another PaaS

Has anyone had experience deploying flyctl in other PaaS providers (ala Heroku)?

I have a build script that does: curl -L https://fly.io/install.sh | sh but when I ssh into the instance and try flyctl I’m getting errors like below:

$ flyctl  --help
ERROR: Cannot find the flyctl executable for x86_64-linux in /opt/project/.gems/ruby/3.0.0/gems/fly.io-rails-0.1.19/exe
If you're using bundler, please make sure you're on the latest bundler version:

  gem install bundler
  bundle update --bundler

Then make sure your lock file includes this platform by running:

  bundle lock --add-platform x86_64-linux
  bundle install

See `bundle lock --help` output for details.

IIRC when you install via the .sh installer, it’s up to you to add ~/.fly/bin to your PATH so you can run the command like that.

I’m unsure what $HOME is in that context but you can search around for the binary and perhaps call it directly.

:thinking:Actually, the more I think on it, the less i’m clear on what “deploying fly in another paas” means - can you describe your use case?

Apologies, should have been more explicit.

We’ve been on render for a while, and I want to deploy a service that can spin up fly.io instances.

During build I run curl -L https://fly.io/install.sh | sh.

I sorta suspect something weirder is going on in render (that output that assumes you’re doing something with ruby is suspicious to me).

Were you able to poke around to find where the flyctl command was installed to?

IIRC when you install via the .sh installer, it’s up to you to add ~/.fly/bin to your PATH so you can run the command like that.

I’m unsure what $HOME is in that context but you can search around for the binary and perhaps call it directly.

It looks like you are using the fly.io-rails gem. It currently includes the binaries for flyctl.

The problem is that you probably aren’t building on an x86_64 machine.

Add the following before bundle install in your Dockerfile:

bundle lock --add-platform x86_64-linux

Note: we are discussing whether including the binaries in the gem is a good idea or not. Let us know what you think.

Thanks Sam! Unfortunately, it doesn’t seem to work. I have a script called render-build.sh that looks like below. This is their suggested implementation.

#!/usr/bin/env bash
# exit on error
set -o errexit

# added by me
# doesn't work even if added at the end, or not present at all
curl -L https://fly.io/install.sh | sh 

# added based on your suggestion, but a form of it was already there
bundle lock --add-platform x86_64-linux 
bundle install

bundle exec rake assets:precompile
bundle exec rake assets:clean
bundle exec rake db:migrate

The project’s Gemfile.lock has

PLATFORMS
  arm64-darwin-21
  ruby
  x86_64-darwin-21
  x86_64-linux
RUBY VERSION
   ruby 3.0.1p64

BUNDLED WITH
   2.3.22

Am I understanding correctly that during the bundle install stage the flyctl binary is compiled?

The gemfile actually has the platform specific binaries. And apparently, they aren’t working for you – which is a vote for removing them from the gem; but that’s a problem for another day, for now lets focus on getting you up and running.

Since you can ssh in, can you verify that there is a flyctl binary in /opt/project/.gems/ruby/3.0.0/gems/fly.io-rails-0.1.19/exe. If you remove the binary can you make forward progress?

Hmm, this is what I’m getting.

$ flyctl
/opt/project/.gems/bin/flyctl:27:in `load': cannot load such file -- /opt/project/.gems/ruby/3.0.0/specifications/exe/flyctl (LoadError)
	from /opt/project/.gems/bin/flyctl:27:in `<main>'

I’ve pushed out a 0.2.0 version of fly.io-rails which no longer includes precompiled executables. Give it a try and see if it addresses this problem.

I’m getting the same thing I’m afraid.

$ flyctl
ERROR: Cannot find the flyctl executable for x86_64-linux in /opt/project/.gems/ruby/3.0.0/gems/fly.io-rails-0.2.0/exe
If you're using bundler, please make sure you're on the latest bundler version:

  gem install bundler
  bundle update --bundler

Then make sure your lock file includes this platform by running:

  bundle lock --add-platform x86_64-linux
  bundle install

See `bundle lock --help` output for details.
$ ls a-l /opt/project/.gems/ruby/3.0.0/gems/fly.io-rails-0.2.0/exe
ls: cannot access 'a-l': No such file or directory
/opt/project/.gems/ruby/3.0.0/gems/fly.io-rails-0.2.0/exe:
flyctl
$ ls -al /opt/project/.gems/ruby/3.0.0/gems/fly.io-rails-0.2.0/exe
total 12
drwxr-sr-x 2 render render 4096 Nov  9 02:50 .
drwxr-sr-x 4 render render 4096 Nov  9 02:50 ..
-rwxr-xr-x 1 render render 1273 Nov  9 02:50 flyctl

I forgot that there was a script that I had to remove to complete the cleanup. Can I get you to try again with 0.2.1?

That did the trick! I added a command to the render-build script to copy the binary somewhere in PATH so I don’t have to tweak the variable itself:

cp /opt/render/.fly/bin/flyctl /opt/render/project/.gems/bin

Thanks Sam & Chris.

1 Like