Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scala not working from Windows Command Line #7821

Closed
scabug opened this issue Sep 7, 2013 · 9 comments
Closed

Scala not working from Windows Command Line #7821

scabug opened this issue Sep 7, 2013 · 9 comments
Assignees
Milestone

Comments

@scabug
Copy link

scabug commented Sep 7, 2013

When I try to invoke the Scala REPL or Scala Compiler from the Windows Command Line:

C:\Program Files (x86)\scala\bin>scala
\scala\bin\scala.bat) was unexpected at this time.

C:\Program Files (x86)\scala\bin>scalac
\scala\bin\scalac.bat) was unexpected at this time.

@scabug
Copy link
Author

scabug commented Sep 7, 2013

Imported From: https://issues.scala-lang.org/browse/SI-7821?orig=1
Reporter: Anish Patel (anishpatel)
Affected Versions: 2.10.2

@scabug
Copy link
Author

scabug commented Sep 7, 2013

Anish Patel (anishpatel) said:
Temporary Resolution: Do not install Scala in a path that includes spaces. By default, the Windows MSI installer will install Scala at "C:\Program Files (x86)\scala", but this can be modified in the installation wizard.

Personally, I installed Scala at "C:\scala".

@scabug
Copy link
Author

scabug commented Oct 20, 2013

@retronym said:
I wasn't able to reproduce on Windows 7. https://dl.dropboxusercontent.com/u/106552/screenshots/Screen%20Shot%202013-10-20%20at%204.42.41%20PM.png

Maybe something special in Windows 8? I'll grab a VM and try it out.

@scabug
Copy link
Author

scabug commented Oct 20, 2013

@retronym said:
Just tried 2.10.3 MSI installer on Windows 8. It offered to install to "C:\Program Files", but I changed that to "C:\Program Files (x86)" to make things harder.

But things work as expected.

https://www.dropbox.com/s/ci2uiudiy5ntxxk/Screen%20Shot%202013-10-20%20at%204.42.41%20PM.png

Anish: could you try a fresh install with 2.10.3 on your machine? Until I hear back, I have to mark this ticket as "incomplete"

@scabug
Copy link
Author

scabug commented Apr 30, 2014

Kevin Meredith (kmeredith) said:
On Windows 7, after installing 2.11.0's MSI, I saw the same error.

To fix it, I installed the 2.11.0's ZIP file, then updated my $PATH.

@scabug
Copy link
Author

scabug commented May 19, 2015

Elvin Pantowidjoyo (Nelvios) said (edited on May 19, 2015 4:33:35 PM UTC):
I'm trying to install Scala 2.11.6 on my Win 7 x64 and this error STILL came out. By doing some research on how to fix a batch file (.bat), I finally found a permanent workaround.
I hope the Scala team can use it on the next version so that Windows x64 users can install Scala without any modification on the .bat file.

The modification must be done on each .bat file under the "scala\bin" directory, which consists of scala.bat, scalac.bat, scaladoc.bat, and scalap.bat.

On every file, right click then choose "Edit".
At the bottom of every file you will find these two subroutines:
:add_cpath and :set_home

In :add_cpath change

    if "%_TOOL_CLASSPATH%"=="" (
        set _TOOL_CLASSPATH={color:red}%~1{color}
    ) else (
        set _TOOL_CLASSPATH={color:red}%_TOOL_CLASSPATH%;%~1{color}
    )

into

    if "%_TOOL_CLASSPATH%"=="" (
        set _TOOL_CLASSPATH={color:red}"%~1"{color}
    ) else (
        set _TOOL_CLASSPATH={color:red}"%_TOOL_CLASSPATH%;%~1"{color}
    )
    {color:red}set _TOOL_CLASSPATH=%_TOOL_CLASSPATH:~1,-1%{color}

And in :set_home change

    set _BIN_DIR=
    for %%i in ({color:red}%~sf0{color}) do set _BIN_DIR=%_BIN_DIR%%%~dpsi
    set _SCALA_HOME=%_BIN_DIR%..

into

    set _BIN_DIR=
    for %%i in ({color:red}"%~sf0"{color}) do set _BIN_DIR=%_BIN_DIR%%%~dpsi
    set _SCALA_HOME=%_BIN_DIR%..

Save them all, then try to run Scala and...
Voila! There's your fix.

@scabug
Copy link
Author

scabug commented Dec 13, 2016

Romeo Disca (thinkrapido) said:
I have this problem with msi 2.12.1:

λ scala
"\scala\bin\scala.bat)" kann syntaktisch an dieser Stelle nicht verarbeitet werden.

I have installed this scala version on a win 7 64 machine.
It resides in c:\Program Files (x86)\scala and has a path entry für the bin folder.

Would appreciate to get this solved.

@scabug
Copy link
Author

scabug commented Dec 20, 2016

@lrytz said:
I just tried this on a 64 bit Windows 10, works for me.. Also installed in "C:\Program Files (x86)\scala"

C:\Users\luc>echo %PATH%
C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\ProgramData\chocolatey\bin;C:\Program Files (x86)\Git\cmd;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\sbt\bin;C:\Program Files\Java\jdk1.8.0_112\bin;C:\Program Files (x86)\scala\bin;C:\Users\luc\AppData\Local\Microsoft\WindowsApps;

C:\Users\luc>scala
Welcome to Scala 2.12.1 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_112).
Type in expressions for evaluation. Or try :help.

scala> 1
res0: Int = 1

@scabug
Copy link
Author

scabug commented Feb 3, 2017

@lrytz said:
Fixed in scala/scala#5666

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants