简体   繁体   中英

Mac OSX Running Application in bash, alias not working

I'm trying to invoke headless Chrome in a rake task. It works in terminal, but doesn't in the rake task.

I've installed Chrome on Mac OS X, and created an alias to the application: alias chrome="/Applications/Google\\ Chrome.app/Contents/MacOS/Google\\ Chrome"

The command chrome --version produces the output: Google Chrome 61.0.3163.100

which chrome produces no output, and that seems odd. chrome --headless --disabled-gpu opens and closes a chrome session, as expected.

I want to run headless chrome in a Rails environment, and conducting rake tests:

namespace :chrome do
  task test_versions: :environment do
    p `chrome --version`
  end
end

Then run the rake task: rake chrome:test_versions resulting in: /User/username/.rvm/gems/ruby-2.4.2/bin/rake: No such file or directory - chrome

EDIT: After a few comments, I'm not addressing the real problem. I want to use rake tasks to invoke chrome headless in Mac.

which chrome produces no output, and that seems odd.

which is an external command which know notihng about Bash's aliases. You can use Bash's type command:

# type chrome

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM