1

I'm trying to write a simple .zsh script to start my webservers upon computer boot.

This works well:

#!/bin/zsh
cd /Users/me/Sites/Vue/mysite && npm run dev &

But this doesn't work:

#!/bin/zsh
cd /Users/me/Sites/Ruby/mysite && rackup &

This is the error message:

❯ ./myscript.zsh
Resolving dependencies...
Could not find proper version of rack (2.2.4) in any of the sources
Run `bundle install` to install missing gems.

Obviously, when I run the command in the terminal window directly, it cds and executes rackup without a problem.

1 Answer 1

2

It seems that either the rackup executable that is in your $PATH when you open a new terminal is not the same one that's in your path when you run your boot script, or else there are other aspects of the environment that are different in the two different scenarios.

You can test this by adding echo $PATH and env at the top of script and examining what is printed for each scenario.

If using the wrong $PATH is the issue, one quick and easy solution would be to call rackup using the full path instead, like so :

# replace /path/to with actual path

cd /Users/me/Sites/Ruby/mysite && /path/to/rackup &
Sign up to request clarification or add additional context in comments.

3 Comments

Another (perhaps better) solution would be to generate a binstub with bundle binstub rackup and then start the application with /Users/me/Sites/Ruby/mysite/bin/rackup. bundler.io/v1.15/man/bundle-binstubs.1.html
If no executable named rackup would be in the PATH, the error message would be something like command not found.
@user1934428 You're right! It could be the case instead that there are multiple rackups on the asker's system, and using the wrong PATH gave them one that didn't have the right gems supporting it. I'll edit my answer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.