Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ERROR (Errno::ENOENT): No such file or directory - aws #720

Closed
dawidof opened this issue Mar 11, 2024 · 10 comments
Closed

ERROR (Errno::ENOENT): No such file or directory - aws #720

dawidof opened this issue Mar 11, 2024 · 10 comments

Comments

@dawidof
Copy link

dawidof commented Mar 11, 2024

My deploy.yml file contains

registry:
  server: <aws account id>.dkr.ecr.eu-west-1.amazonaws.com
  username: AWS
  password: <%= %x(aws ecr get-login-password --region eu-west-1 --profile linked) %>

It tries to execute aws command, but returns this error ERROR (Errno::ENOENT): No such file or directory - aws, locally in terminal this command returns token

@morgoth
Copy link
Contributor

morgoth commented Mar 11, 2024

I'm using AWS registry and this way of getting token <%= %x(aws ecr get-login-password) %> works for me.
Is your command working whne invoked from irb console, ie %x(aws ecr get-login-password --region eu-west-1 --profile linked)

Anyway, this doesn't look like kamal issue but some local misconfiguration

@dawidof
Copy link
Author

dawidof commented Mar 11, 2024

Is your command working whne invoked from irb console, ie %x(aws ecr get-login-password --region eu-west-1 --profile linked)

yes, in irb token returns


kamal setup in verbose mode

kamal setup -v                                                                                                                                                                                                        ✭
  Finished all in 0.0 seconds
  ERROR (Errno::ENOENT): No such file or directory - aws
(erb):7:in ``'
(erb):7:in `<main>'
/usr/local/lib/ruby/3.2.0/erb.rb:429:in `eval'
/usr/local/lib/ruby/3.2.0/erb.rb:429:in `result'
/usr/local/bundle/gems/kamal-1.3.1/lib/kamal/configuration.rb:30:in `load_config_file'
/usr/local/bundle/gems/kamal-1.3.1/lib/kamal/configuration.rb:23:in `block in load_config_files'
/usr/local/bundle/gems/kamal-1.3.1/lib/kamal/configuration.rb:23:in `each'
/usr/local/bundle/gems/kamal-1.3.1/lib/kamal/configuration.rb:23:in `inject'
/usr/local/bundle/gems/kamal-1.3.1/lib/kamal/configuration.rb:23:in `load_config_files'
/usr/local/bundle/gems/kamal-1.3.1/lib/kamal/configuration.rb:16:in `create_from'
/usr/local/bundle/gems/kamal-1.3.1/lib/kamal/commander.rb:14:in `config'
/usr/local/bundle/gems/kamal-1.3.1/lib/kamal/commander.rb:121:in `hook'
/usr/local/bundle/gems/kamal-1.3.1/lib/kamal/cli/base.rb:144:in `run_hook'
/usr/local/bundle/gems/kamal-1.3.1/lib/kamal/cli/base.rb:85:in `mutating'
/usr/local/bundle/gems/kamal-1.3.1/lib/kamal/cli/main.rb:5:in `block in setup'
/usr/local/bundle/gems/kamal-1.3.1/lib/kamal/cli/base.rb:75:in `print_runtime'
/usr/local/bundle/gems/kamal-1.3.1/lib/kamal/cli/main.rb:4:in `setup'
/usr/local/bundle/gems/thor-1.3.0/lib/thor/command.rb:28:in `run'
/usr/local/bundle/gems/thor-1.3.0/lib/thor/invocation.rb:127:in `invoke_command'
/usr/local/bundle/gems/thor-1.3.0/lib/thor.rb:527:in `dispatch'
/usr/local/bundle/gems/thor-1.3.0/lib/thor/base.rb:584:in `start'
/usr/local/bundle/gems/kamal-1.3.1/bin/kamal:9:in `<top (required)>'
/usr/local/bundle/bin/kamal:25:in `load'
/usr/local/bundle/bin/kamal:25:in `<main>'

when I change my deploy.yml to

---
servers:
  - 192.168.1.100
registry:
  server: whatever
  username: AWS
  password: <%= %x(aws_test ecr get-login-password --region eu-west-1 --profile linked) %> # here aws_test not aws

it returns

kamal setup -v                                                                                                                                                                                                        ✭
  Finished all in 0.0 seconds
  ERROR (Errno::ENOENT): No such file or directory - aws_test
(erb):7:in ``'
(erb):7:in `<main>'
/usr/local/lib/ruby/3.2.0/erb.rb:429:in `eval'
/usr/local/lib/ruby/3.2.0/erb.rb:429:in `result'
/usr/local/bundle/gems/kamal-1.3.1/lib/kamal/configuration.rb:30:in `load_config_file'
/usr/local/bundle/gems/kamal-1.3.1/lib/kamal/configuration.rb:23:in `block in load_config_files'
/usr/local/bundle/gems/kamal-1.3.1/lib/kamal/configuration.rb:23:in `each'
/usr/local/bundle/gems/kamal-1.3.1/lib/kamal/configuration.rb:23:in `inject'
/usr/local/bundle/gems/kamal-1.3.1/lib/kamal/configuration.rb:23:in `load_config_files'
/usr/local/bundle/gems/kamal-1.3.1/lib/kamal/configuration.rb:16:in `create_from'
/usr/local/bundle/gems/kamal-1.3.1/lib/kamal/commander.rb:14:in `config'
/usr/local/bundle/gems/kamal-1.3.1/lib/kamal/commander.rb:121:in `hook'
/usr/local/bundle/gems/kamal-1.3.1/lib/kamal/cli/base.rb:144:in `run_hook'
/usr/local/bundle/gems/kamal-1.3.1/lib/kamal/cli/base.rb:85:in `mutating'
/usr/local/bundle/gems/kamal-1.3.1/lib/kamal/cli/main.rb:5:in `block in setup'
/usr/local/bundle/gems/kamal-1.3.1/lib/kamal/cli/base.rb:75:in `print_runtime'
/usr/local/bundle/gems/kamal-1.3.1/lib/kamal/cli/main.rb:4:in `setup'
/usr/local/bundle/gems/thor-1.3.0/lib/thor/command.rb:28:in `run'
/usr/local/bundle/gems/thor-1.3.0/lib/thor/invocation.rb:127:in `invoke_command'
/usr/local/bundle/gems/thor-1.3.0/lib/thor.rb:527:in `dispatch'
/usr/local/bundle/gems/thor-1.3.0/lib/thor/base.rb:584:in `start'
/usr/local/bundle/gems/kamal-1.3.1/bin/kamal:9:in `<top (required)>'
/usr/local/bundle/bin/kamal:25:in `load'
/usr/local/bundle/bin/kamal:25:in `<main>'

@dawidof
Copy link
Author

dawidof commented Mar 11, 2024

Kamal::Cli::Main.new.setup works in rails c

3.2.2 :002 > Kamal::Cli::Main.new.setup
  INFO [616be28b] Running /usr/bin/env mkdir -p .kamal on 34.243.90.110
  INFO [616be28b] Finished in 1.066 seconds with exit status 0 (successful).
Acquiring the deploy lock...
Ensure Docker is installed...
  INFO [64a095cd] Running docker -v on 34.243.90.110
  INFO [64a095cd] Finished in 0.279 seconds with exit status 0 (successful).
  INFO [f96bc497] Running /usr/bin/env mkdir -p .kamal on 34.243.90.110
  INFO [f96bc497] Finished in 0.187 seconds with exit status 0 (successful).
Push env files...
  INFO [d99d2446] Running /usr/bin/env mkdir -p .kamal/env/roles on 34.243.90.110
  INFO [d99d2446] Finished in 0.176 seconds with exit status 0 (successful).

...

@wenderjean
Copy link

The error comes from %x() that's trying to execute a system command. The error suggests you don't have aws_cli installed or it is not visible somehow.

Look

$ irb
irb(main):002> %x(aws_test --version)
(irb):2:in ``': No such file or directory - aws_test (Errno::ENOENT)

irb(main):001> %x(aws --version)
"aws-cli/2.15.10 Python/3.11.6"

@igor-alexandrov
Copy link
Contributor

@dawidof are you getting this error in the GitHub Actions CI?

@dawidof
Copy link
Author

dawidof commented Mar 26, 2024

@dawidof are you getting this error in the GitHub Actions CI?

Refused from Kamal, in my case I'm using aws with load balancers, vpc and many other services from Amazon, and Kamal is not really made for such things, I'm using an old terraform and it works great, github actions also configured to build container and push to ECR.

@igor-alexandrov
Copy link
Contributor

It seems you do not understand how Kamal works. The configuration file is getting read locally in the environment where you executed the kamal deploy command. If you use GitHub Actions, then the aws command should exist on your runner. The correct way to pass secrets to the Kamal is by using environment variables:

password:
    - KAMAL_REGISTRY_PASSWORD

In this case, KAMAL_REGISTRY_PASSWORD can be set in the GitHub Actions workflow file by using https://github.com/aws-actions/amazon-ecr-login action.

@morgoth
Copy link
Contributor

morgoth commented Apr 18, 2024

@dawidof Can this issue be closed? Looks like it's not related to the kamal tool but the local setup.

@dawidof
Copy link
Author

dawidof commented Apr 18, 2024

@dawidof Can this issue be closed? Looks like it's not related to the kamal tool but the local setup.

As for me, it's related to Kamal, %x() is not being executed when trying to setup Kamal, but in irb works.

@lucasmncastro
Copy link

This happened with me because I was using kamal with docker and awscli wasn't there.

I fixed installing the gem.

@djmb djmb added the Dockerized label May 2, 2024
@dhh dhh closed this as completed May 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants