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

Shadow can fail trying to reference deps.edn git dependencies on MS-Windows #966

Closed
ikappaki opened this issue Dec 4, 2021 · 2 comments
Closed

Comments

@ikappaki
Copy link
Contributor

ikappaki commented Dec 4, 2021

Hi,

I've encountered an issue with shadow failing on MS-Windows when the project root directory and a library downloaded via deps.edn wiht git are in different drives (e.g. D: and C: respectively):

d:\clj\issues\issue-shadow-cljs-rel-path>powershell -command clojure -M:shadow watch browser
Downloading: thheller/shadow-cljs/2.16.6/shadow-cljs-2.16.6.pom from clojars
Downloading: thheller/shadow-cljs/2.16.6/shadow-cljs-2.16.6.jar from clojars
[2021-12-04 16:17:14.341 - WARNING] TCP Port 9630 in use.
[2021-12-04 16:17:14.355 - WARNING] TCP Port 9631 in use.
failed to start service
{:id :classpath}
ExceptionInfo: failed to start service
        shadow.runtime.services/start-many/fn--9691 (services.clj:135)
...
        clojure.main.main (main.java:40)
Caused by:
IllegalArgumentException: 'other' has different root
        sun.nio.fs.WindowsPath.relativize (WindowsPath.java:404)
        sun.nio.fs.WindowsPath.relativize (WindowsPath.java:42)
        shadow.build.classpath/project-rel-path (classpath.clj:719)
        shadow.build.classpath/project-rel-path (classpath.clj:718)
        shadow.build.classpath/find-fs-resources* (classpath.clj:767)
        shadow.build.classpath/find-fs-resources* (classpath.clj:764)
        shadow.build.classpath/find-fs-resources (classpath.clj:792)
        shadow.build.classpath/find-fs-resources (classpath.clj:791)
        shadow.build.classpath/find-resources (classpath.clj:801)
        shadow.build.classpath/find-resources (classpath.clj:795)
        shadow.build.classpath/index-path* (classpath.clj:1034)
        shadow.build.classpath/index-path* (classpath.clj:1031)
 ...
        shadow.build.classpath/index-classpath/fn--11375/fn--11376 (classpath.clj:1167)
...
        shadow.build.classpath/index-classpath/fn--11375 (classpath.clj:1167)
        shadow.build.classpath/index-classpath (classpath.clj:1166)
        shadow.build.classpath/index-classpath (classpath.clj:1161)
        shadow.build.classpath/index-classpath (classpath.clj:1163)
        shadow.build.classpath/index-classpath (classpath.clj:1161)
        shadow.cljs.devtools.server.common/fn--16790 (common.clj:95)
        shadow.cljs.devtools.server.common/fn--16790 (common.clj:93)
...

This is because it cannot find a relative path between the Project and the downloaded git library.

To reproduce on MS-Windows, create the below project on a different drive (say somewhere on drive D:) than clojure cli stores the github dependencies (normally stored on drive C: under C:\Users\<username>\.gitlibs):

e.g. under D:\clj\issues\issue-shadow-cljs-rel-path\

  1. shadow-cljs.edn
{:deps {:aliases [:shadow]}
 :builds {:browser {:target :browser
                    :output-to "public/js/viewer.js"
                    :output-dir "public/js"
                    }}}
  1. deps.edn
{:paths ["src"]
 :deps {re-frame/re-frame {:git/url "https://github.com/nextjournal/freerange"
                           :git/sha "8cf68c30722a4c6f8f948a134c900d7a656ecad4"}
        }
 
 :aliases
 {:shadow {:extra-deps {thheller/shadow-cljs {:mvn/version "2.16.6"}}
           :main-opts ["-m" "shadow.cljs.devtools.cli"]}
  }}
  1. invoke shadow
d:\clj\issues\issue-shadow-cljs-rel-path> powershell -command clojure -M:shadow watch browser

The above error is returned.

The cause of the issue is that shadow is trying to find a relative path from the project to the dep with shadow.build.classpath/project-rel-path, but it cannot and throws the above example. There is no relative path because there is no common root between D:\clj\issues\issue-shadow-cljs-rel-path and C:\Users\ikappaki\.gitlibs\libs\re-frame\re-frame\8cf68c30722a4c6f8f948a134c900d7a656ecad4\src (one starts with D: the other with C:).

If we relocate the project on the C drive, then the above succeeds, since there is a relative path between the two C:\clj\issues\issue-shadow-cljs-rel-path and C:\Users\ikappaki\.gitlibs\libs\re-frame\re-frame\8cf68c30722a4c6f8f948a134c900d7a656ecad4\src, namely ..\..\..\Users\ikappaki\.gitlibs\libs\re-frame\re-frame\8cf68c30722a4c6f8f948a134c900d7a656ecad4\src. The same works on *nix, because there is always a common root / amongst any absolute paths, thus a relative path with ../... can always be created.

It is not obvious to me what the correct solution is, have shadow.build.classpath/project-rel-path return nil? Though the callers appear to always make use of the return value.

Thanks!

@thheller
Copy link
Owner

thheller commented Dec 5, 2021

Should be fixed as of 2.16.7.

@ikappaki
Copy link
Contributor Author

ikappaki commented Dec 5, 2021

Should be fixed as of 2.16.7.

Thanks! tested to work as expected.

filipesilva added a commit to athensresearch/athens that referenced this issue Apr 20, 2022
Tried running an Athens dev build on Windows and ran into thheller/shadow-cljs#966, which is solved by updating Shadow-CLJS.

Shadow-CLJS and CLJS have to be updated together because that's just how Shadow-CLJS works.

Tick had to be updated because it broke when updating the other two.
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