最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

shell - zsh script command not finding ruby gem - Stack Overflow

programmeradmin2浏览0评论

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.

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.

Share Improve this question asked Mar 15 at 13:20 thiebothiebo 1,4472 gold badges23 silver badges44 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 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 &
发布评论

评论列表(0)

  1. 暂无评论