Filename too long sbt

前端 未结 5 1225
谎友^
谎友^ 2020-12-08 10:11

I am getting an error saying I have a file that is too long in sbt.

 [info] Compiling 29 Scala sources to /home/chris/dev/suredbits-core/target/scala-2.11         


        
相关标签:
5条回答
  • 2020-12-08 10:30

    This is how I solved my problem

    mkdir /tmp/myproject-target
    cd ~/workspace/myproject
    rm -rf target
    ln -s /tmp/myproject-target target
    
    0 讨论(0)
  • 2020-12-08 10:30

    Try using a shell script like this:

    #!/bin/sh
    
    for file in *; do {
            echo -m "$file" | wc -m;
            echo "$file"
    }
    done
    

    Running this in your src/main/scala directory should show you which files have a name with more than 254 chars. I hope this answers your question.

    0 讨论(0)
  • 2020-12-08 10:47

    I encountered this problem in IntelliJ Ultimate 2016.1.2 (which resembles Intellij 14). I solved it by setting:

    -Xmax-classfile-name 78 
    

    In File > Settings... > Build, Execution, Deployment > Compiler > Scala Compiler > Additional Compiler Options.

    NOTE: there is a space between the option name and its value ("78"), not an equals sign.

    0 讨论(0)
  • 2020-12-08 10:49

    If your /home is an encrypted file system (e.g. LUKS), you might run into this issue.

    Setting max-classfile-name to 254 is the default (or it might be 255) - so you're not reducing it much. You should probably be considering something closer to a max length of 70 - 100. You can set it for all your projects by creating ~/.sbt/0.13/local.sbt with the scalac override:

    scalacOptions ++= Seq("-Xmax-classfile-name","78")
    
    0 讨论(0)
  • 2020-12-08 10:54
    • Setting the file length limits might be unsafe, I could not find any official documentation that this solution is safe.
    • Using un-encrypted directory is not safe.

    I want to offer a different approach:

    • install veracrypt (in ubuntu with apt)
    • create a non-encrypted directory (outside the encrypted user home dir)
    • create a veracrypt file container in the new directory
    • mount the container in

    • sbt works fine even if the mount point is in the encrypted directory)
    • It is possible to create the container with a complex password and mount on login

      veracrypt -t --pim=0 --protect-hidden=no -k "" -p $PASSWORD $ENCRYPTED_CONTAINER $MOUNT_DIR

    0 讨论(0)
提交回复
热议问题