问题描述
我试图用Scala语言的简单例子。我成功安装了
sbt
。运行 sbt -h
我看到sbt的帮助消息: 使用:sbt [options]
-h | -help打印此消息
-v | -verbose这个跑步者是chattier
-d | -debug set sbt log level to debug
-no-colors disable ANSI颜色代码
-sbt-create start sbt即使当前目录不包含sbt项目
-sbt-dir< path>全局设置/插件目录的路径(默认值:〜/ .sbt)
-sbt-boot< path>共享引导目录的路径(默认值:0.11系列中的〜/ .sbt / boot)
-ivy< path>路径到本地常春藤仓库(默认值:〜/ .ivy2)
-mem< integer>设置内存选项(默认值:1536,这是-Xms1536m -Xmx1536m -XX:MaxPermSize = 384m -XX:ReservedCodeCacheSize = 192m)....
但是当我试图在目录中运行scala作业(这是Coursera课程)时,我发现错误:
code> nazar_art @ nazar-desctop:〜/ scala / example $ sbt
检测到sbt版本0.12.1
启动sbt:使用-help调用其他选项
初始化期间发生错误的VM
无法为对象堆保留足够的空间
但应该打开sbt命令提示。 smt这样:
shell $ cd / path / to / progfun-project-directory#这是操作系统的shell
shell $ sbt
> _#这是sbt shell
更新:
添加以下行后
java -Xms64M -Xmx256M -Xss1M -XX:+ CMSClassUnloadingEnabled - XX:MaxPermSize = 64M -jar
dirname $ 0 /sbt-launch.jar$ @
在 / usr / bin
我看到下一个输出:
nazar_art @ nazar-desctop:/ usr / bin $ sbt
bash:/ usr / bin / sbt:Permission denied
nazar_art @ nazar-desctop:/ usr / bin $ sudo sbt
sudo :sbt:command not found
- 为什么会这样?
- 如何解决这个问题?
首先,名称(和您安装sbt的文件夹名称)不能包含!。这可能也适用于其他特殊字符。甚至,我建议将SBT安装在路径上没有空格的文件夹(对于示例文件夹也是一样的)。
例如,如果您已经安装了SBT (或示例文件夹),如下所示:
/ Users / dashti /我的程序/ sbt-0.12.1
您可以重新安装一个如下所示的路径:
/Users/dashti/MyPrograms/sbt-0.12.1
通过应用此命名更改,如果错误消失,请忽略此帖的其余部分。
否则,要修复上述错误,请先查找sbt可执行脚本,然后编辑它并纠正其中的任何问题:
如果您使用的是基于UNIX的操作系统,请按照下列步骤操作:
1-查找SBT:打开终端并键入以下命令:
其中sbt
,您将收到一条路径,如:
/Users/dashti/Documents/scala-2.10.0/b in / sbt
在这个文件中,有一个执行java程序的命令,如: / p>
java -Xms512M -Xmx1024M -Xss1M -XX:+ CMSClassUnloadingEnabled -XX:MaxPermSize = 128M -jar`dirname $ 0` / sbt- launch.jar$ @
2-编辑sbt脚本:通过在终端中输入此命令: / p>
vim /Users/dashti/Documents/scala-2.10.0/bin/sbt
您将能够编辑此文件,也许您应该将内存使用参数更改为较低的规格(您应该考虑是否有足够的RAM要运行sbt)。例如,这将是一个更好的选择:
java -Xms64M -Xmx256M -Xss1M -XX:+ CMSClassUnloadingEnabled -XX: MaxPermSize = 64M -jar`dirname $ 0` / sbt-launch.jar$ @
I tried to work with easy example of scala language.I installed sbt
successfully. When run sbt -h
I see help message from sbt:
Usage: sbt [options]
-h | -help print this message
-v | -verbose this runner is chattier
-d | -debug set sbt log level to debug
-no-colors disable ANSI color codes
-sbt-create start sbt even if current directory contains no sbt project
-sbt-dir <path> path to global settings/plugins directory (default: ~/.sbt)
-sbt-boot <path> path to shared boot directory (default: ~/.sbt/boot in 0.11 series)
-ivy <path> path to local Ivy repository (default: ~/.ivy2)
-mem <integer> set memory options (default: 1536, which is -Xms1536m -Xmx1536m -XX:MaxPermSize=384m -XX:ReservedCodeCacheSize=192m) ....
but when I tried to run in the directory with scala assignments (it's Coursera course) I caught error:
nazar_art@nazar-desctop:~/scala/example$ sbt
Detected sbt version 0.12.1
Starting sbt: invoke with -help for other options
Error occurred during initialization of VM
Could not reserve enough space for object heap
but it should open the sbt command prompt. Smt like this:
shell$ cd /path/to/progfun-project-directory # This is the shell of the operating system
shell$ sbt
> _ # This is the sbt shell
UPDATE:
After I add this following line
java -Xms64M -Xmx256M -Xss1M -XX:+CMSClassUnloadingEnabled -XX:MaxPermSize=64M -jar
dirname $0/sbt-launch.jar "$@"
at /usr/bin
I see next output:
nazar_art@nazar-desctop:/usr/bin$ sbt
bash: /usr/bin/sbt: Permission denied
nazar_art@nazar-desctop:/usr/bin$ sudo sbt
sudo: sbt: command not found
- Why this happen?
- How to solve this issue?
First of all, The example folder name (and the folder name that you have installed sbt) cannot include "!". this probably applies to other special characters as well. Even, I recommend to install SBT in a folder that has no space on its path (and the same thing for examples folder).
For example, if you have installed SBT (or examples folder) on a path like:
/Users/dashti/My Programs/sbt-0.12.1
You can re-install it a path like:
/Users/dashti/MyPrograms/sbt-0.12.1
By applying this naming change, if the error is gone, please ignore the rest of this post.
Otherwise, to fix the mentioned error, first find sbt executable script, then edit it and correct any problem in it:
If you are using a UNIX-based operating system, please follow these steps:
1- Find SBT: Open a terminal and type this command:
which sbt
and you will receive a path like:
/Users/dashti/Documents/scala-2.10.0/bin/sbt
and in this file, there is a command for executing a java program, like:
java -Xms512M -Xmx1024M -Xss1M -XX:+CMSClassUnloadingEnabled -XX:MaxPermSize=128M -jar `dirname $0`/sbt-launch.jar "$@"
2- Edit sbt script: by entering this command in terminal:
vim /Users/dashti/Documents/scala-2.10.0/bin/sbt
you will be able to edit this file and maybe you should change the memory usage arguments to a lower specification ( You should think about whether you have enough RAM to be running the sbt). For example, this one will be a better choice:
java -Xms64M -Xmx256M -Xss1M -XX:+CMSClassUnloadingEnabled -XX:MaxPermSize=64M -jar `dirname $0`/sbt-launch.jar "$@"
这篇关于scala:在Ubuntu 12.04初始化VM时发生错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!