在命令SBT(斯卡拉)通过SSH结果没有找到,但如果我做我自己的作品 [英] sbt (Scala) via SSH results in command not found, but works if I do it myself

查看:172
本文介绍了在命令SBT(斯卡拉)通过SSH结果没有找到,但如果我做我自己的作品的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我试图做一些事情,包括运行 SBT 通过SSH命令,这就是我想:

So I'm trying to do something that involves running sbt over an SSH command, and this is what I'm trying:

ssh my_username@<server ip> "cd <project folder>; sbt 'run-main Foo' "

当我这样做,不过,我得到一个错误信息:庆典:SBT:命令未找到

When I do that however, I get an error message: bash: sbt: command not found

然后我去SSH到服务器自己, CD 到项目文件夹,然后运行 SBT运行主美孚,一切都很好地工作。我已经检查,以确保 SBT 是在 $ PATH 通过远程服务器上的变量SSH my_username @&LT;服务器的IP&GT; 回声$ PATH,它显示了正确的值。

Then I go SSH into the server myself, cd to the project folder, and run sbt 'run-main Foo' and everything works nicely. I have checked to make sure sbt is on the $PATH variable on the remote server via ssh my_username@<server ip> "echo $PATH" and it shows the correct value.

我觉得这是一个简单的解决,但不能看着办吧...帮助吗?
谢谢!
-kstruct

I feel like this is a simple fix, but cannot figure it out... help? Thanks! -kstruct

推荐答案

当您登录时,庆典运行作为一个交互的shell。当你直接通过 SSH运行命令时,bash运行作为非交互的shell,因此,不同的初始化文件都被(见该bash的手册页完全一致)。有许多方法来解决这个问题,例如:

When you log in, bash is run as an interactive shell. When you run commands directly through ssh, bash is run as a non-interactive shell, and therefore different initialization files are sourced (see the bash manual pages for which exactly). There are a number of ways to fix this, e.g.:


  • 使用的完整路径 SBT 直接通过 SSH 调用它时

  • 编辑的.bashrc 和丢失的目录会添加到 PATH 环境变量

  • Use the full path to sbt when calling it directly through ssh
  • Edit .bashrc and add the missing directories to the PATH environment variable

请注意您的测试 SSH my_username @&LT;服务器的IP&GT; 回声$ PATH实际打印 PATH 你的客户,而不是你的服务器上,因为双引号。使用 SSH my_username @&LT;服务器的IP&GT; 回响$ PATH SSH my_username @&LT;服务器的IP&GT; ENV 来从服务器的环境中打印 PATH 。当使用 ENV 检查,您将看到 PS1 仅在交互式shell设置。

Note that your test ssh my_username@<server ip> "echo $PATH" actually prints PATH on your client, not your server, because of the double quotes. Use ssh my_username@<server ip> 'echo $PATH' or ssh my_username@<server ip> env to print PATH from the server's environment. When checking using env, you will see that PS1 is only set in interactive shells.

这篇关于在命令SBT(斯卡拉)通过SSH结果没有找到,但如果我做我自己的作品的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆