Multiple users on one system can't use Spoofax language
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 thevfs-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:
Submitted by Oskar van Rest on 19 May 2016 at 03:19
((DefaultFileSystemManager) VFS.getManager()).setReplicator(replicator);
where replicator is created like above.
Issue Log
You can override the
DefaultFileSystemManagerProvider
by creating a module that inherits fromSpoofaxModule
, and overriding thebindResource
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? :)
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.
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
Merged, thanks!
somehow my pull request did not have any affect. This is still an issue in 2.1.0. Not sure where to set the replicator if not in that file.
It is still creating
/tmp/vfs-cache/
instead of/tmp/vfs-cache<longnumber>/
?
Yes still the
/tmp/vfs-cache
. Martin ran into it with GM (Spoofax 2.1.0). With PGQL I was still using the workaround.
Issue is solved now. At least in Spoofax 2.3.0 it is no longer creating
/tmp/vfs-cache/
. I think previously we tested it wrongly and forgot to usespoofax.resourceService.resolve(..)
instead ofVFS.getManager().resolveFile(..)
in a few places. Closing the issue.
Log in to post comments