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

Possible issue with usage of File.getCanonicalPath() #50

Open
iadcode opened this issue Aug 31, 2016 · 2 comments
Open

Possible issue with usage of File.getCanonicalPath() #50

iadcode opened this issue Aug 31, 2016 · 2 comments

Comments

@iadcode
Copy link

iadcode commented Aug 31, 2016

Pull Request #47 changed the sources list to be transformed through File.getCanonicalPath().
Additionally, in SbtJsTask.executeSourceFilesJs, a file is transformed by File.getCanonicalPath().

I question the use of .getCanonicalPath() over .getAbsolutePath(). On UNIX environments, .getCanonicalPath() will resolve symbolic links. With the inconsistent usage of .getCanonicalPath() throughout SbtJsTask, I think this causes issues when mapping output files to source files, or trying to locate source/output files relative to some folders.

I have created an example using Play to demonstrate this in practice at objectmastery/canonical-error-example. The example uses a project/subproject setup, with a symbolic link from the main project to the sub project. This reflects a setup I already have working fine on Windows, with a subproject being symbolically linked to by multiple other main projects (code sharing! yay!).

Of course, there's always a chance .getCanonicalPath() is all fine and I'm just doing something strange, so feel free to point that out instead.

@iadcode
Copy link
Author

iadcode commented Aug 31, 2016

The solution may also be to consistently use .getCanonicalPath() everywhere instead, so you're never dealing with a path with a symbolic link.

@jroper
Copy link
Member

jroper commented Sep 4, 2017

I think it should probably use getAbsolutePath, sbt's relativeTo will fail if there are symlinks underneath a the parent directory to somewhere outside of the structure.

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

No branches or pull requests

2 participants