Closed aliismayilov closed 4 months ago
The correct format is:
./bin/kamal app exec -e='STATEMENT_TIMEOUT:0' 'bin/rails db:vacuum'
The correct format is:
./bin/kamal app exec -e='STATEMENT_TIMEOUT:0' 'bin/rails db:vacuum'
Sorry @djmb for late reply, but even with the latest kamal running locally, none of the following work:
❯ kamal app exec -e='STATEMENT_TIMEOUT:0' 'bin/rails db:vacuum'
ERROR: "kamal app exec" was called with no arguments
Usage: "kamal app exec [CMD]"
❯ kamal app exec --env='STATEMENT_TIMEOUT:0' 'bin/rails db:vacuum'
ERROR: "kamal app exec" was called with no arguments
Usage: "kamal app exec [CMD]"
❯ kamal app exec -e 'STATEMENT_TIMEOUT:0' 'bin/rails db:vacuum'
ERROR: "kamal app exec" was called with no arguments
Usage: "kamal app exec [CMD]"
I can confirm that the problem is in thor gem.
Reproducible small example:
#!/usr/bin/env ruby
require "thor"
class Kamal < Thor
def self.exit_on_failure? = true
desc "exec command", "an exec task"
method_option :env, type: :hash
def exec(command)
puts "these are the options: #{options}"
puts "this is the command: #{command}"
end
end
Kamal.start
# ./kamal.rb exec --env='STATEMENT_TIMEOUT:0' 'bin/rails db:vacuum' => fails
# ./kamal.rb exec 'bin/rails db:vacuum' --env='STATEMENT_TIMEOUT:0' => works
# ./kamal.rb exec --env='STATEMENT_TIMEOUT:0' 'bin/rails vacuum' => works
# ./kamal.rb exec 'bin/rails vacuum' --env='STATEMENT_TIMEOUT:0' => works
I'll try to see if I can get to submit a PR to the upstream.
TLDR: Use ./bin/kamal app exec 'bin/rails db:vacuum' -e 'STATEMENT_TIMEOUT:0'
Not sure if it's an issue with thor gem parsing the arguments or with kamal, but the following command doesn't work:
While the following work:
Setting additional ENV variables was recently implemented: https://github.com/basecamp/kamal/pull/751