Creating a separate issue for this, since it is actually quite a major problem:

Spoofax replicates the stratego.jar and the stratego-javastrat.jar that are inside the binary of a language (e.g. pgql.spoofax-language), onto the file system, into a directory /tmp/vfs-cache/.
The problem with this is that if a user A first creates the vfs-cache directory, then a user B may not have write access to it and Spoofax will thus crash for him.

Ultimately, Spoofax should use some virtual file system to replicate files to. Alternatively, the replicator should not use a static temporary directory but a random one:

String baseTmpDir = System.getProperty("java.io.tmpdir");
File tempDir = new File(baseTmpDir, "vfs_cache" + new Random().nextLong()).getAbsoluteFile();
DefaultFileReplicator replicator = new DefaultFileReplicator(tempDir);

Maybe do that in org.metaborg.core/src/main/java/org/metaborg/core/resource/DefaultFileSystemManagerProvider.java?

It's kind of a VFS bug IMO, but I think you'll have to work around it.

In the meantime, this is a temporary workaround that Spoofax users can use:

((DefaultFileSystemManager) VFS.getManager()).setReplicator(replicator); where replicator is created like above.

Submitted by Oskar van Rest on 19 May 2016 at 03:19

On 19 May 2016 at 13:11 Gabriël Konat commented:

You can override the DefaultFileSystemManagerProvider by creating a module that inherits from SpoofaxModule, and overriding the bindResource method there to inject a different FileSystemManagerProvider:

@Override protected void bindResource() {
    bind(ResourceService.class).in(Singleton.class);
    bind(IResourceService.class).to(ResourceService.class);
    autoClosableBinder.addBinding().to(ResourceService.class);

    bind(FileSystemManager.class).toProvider(PGXFileSystemManagerProvider.class).in(Singleton.class);
}

However, the change you propose makes sense. Can you make that change (licensed under Apache 2.0) and open a PR, or is that against Oracle policy? :)


On 19 May 2016 at 13:15 Gabriël Konat commented:

Also, about your other comment that Spoofax does not clean up its temporary resources, it actually does!

If you set up the Spoofax facade via the try-with-resources statement like shown here, Spoofax will clean up temporary resources when exiting the try statement.


On 19 May 2016 at 21:47 Oskar van Rest commented:

Ok thanks! Didn't realize it was already cleaning up.

Very happy to make my first Apache 2.0 PRs :P
https://github.com/metaborg/spoofax/pull/16


On 20 May 2016 at 10:22 Gabriël Konat commented:

Merged, thanks!


On 20 May 2016 at 10:22 Gabriël Konat closed this issue.

Log in to post comments