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

OutputDirectory problem on Windows #45

Closed
rdebusscher opened this issue May 15, 2013 · 16 comments
Closed

OutputDirectory problem on Windows #45

rdebusscher opened this issue May 15, 2013 · 16 comments

Comments

@rdebusscher
Copy link

When running on windows, I receive the following issue

Caused by: org.jruby.exceptions.RaiseException: (IOError) target directory does not exist: C:/opensource/StatelessPrime/angularJS/AngularPrime/trunk/C:/opensource/StatelessPrime/angularJS/AngularPrime/trunk/C:/opensource/StatelessPrime/angularJS/AngularPrime/trunk/target/generated-docs
at RUBY.render(jar:file:c:/maven_repository/org/asciidoctor/asciidoctor-java-integration/0.1.2/asciidoctor-java-integration-0.1.2.jar!/gems/asciidoctor-0.1.2/lib/asciidoctor.rb:811)

So it seems that path passed to JRuby script is expected to be relative to current directory but full path is supplied.

@lordofthejars
Copy link
Member

Yes I have just noted this behaviour today in a Windows machie. It is not a problem with relative or absolute path, if you pass a relative path it fails too. The major problem is that in linux it works as expected (in fact there are a lot unit tests which tests that feature), so I am not pretty sure what is exactly the reason. @LightGuard have you tried running the plugin on a Windows machine? I will try to take a look too today.

@rdebusscher
Copy link
Author

Tried a few things and issues seems not located in asciidoctor-maven-plugin or asciidoctor-java-integration code.

When I add the following line

         // temp hack, see https://github.com/asciidoctor/asciidoctor-java-integration/issues/26
         final Map<String, Object> options = optionsBuilder.asMap();
+        options.put("to_dir", "/target/docs");

         options.put("imagesdir", imagesDir);

this is within the org.asciidoc.maven.AsciidoctorMojo#execute method, then the document is generated in the directory c:/target/docs.

So the JRuby threats all file names that doesn't start with / as relative and thus prepend it with the current directory.

@LightGuard
Copy link
Member

No, I have not tried running this on a windows machine, looks like I need to get my XP VM setup to do that (I think it has enough space in it). Being that this is a maven plugin I figured it was reasonable to assume things would be relative to the project, but we're seeing a problem on Windows where this is the full path, correct?

@lordofthejars
Copy link
Member

yes, internally in asciidoctor-java-integration, I am calling getAbsolutePath() method from File class, so I think we can consider all paths as absolutes.

@LightGuard
Copy link
Member

Okay, should I prepend the absolute path of the project then?

On Wed, May 15, 2013 at 9:39 AM, Alex Soto notifications@github.com wrote:

yes, internally in asciidoctor-java-integration, I am calling
getAbsolutePath() method from File class, so I think we can consider all
paths as absolutes.


Reply to this email directly or view it on GitHubhttps://github.com//issues/45#issuecomment-17946669
.

Jason Porter
http://en.gravatar.com/lightguardjp

@lordofthejars
Copy link
Member

Not required you Can even use the . path and would fail too

El dimecres 15 de maig de 2013, Jason Porter ha escrit:

Okay, should I prepend the absolute path of the project then?

On Wed, May 15, 2013 at 9:39 AM, Alex Soto <notifications@github.com<javascript:_e({}, 'cvml', 'notifications@github.com');>>
wrote:

yes, internally in asciidoctor-java-integration, I am calling
getAbsolutePath() method from File class, so I think we can consider all
paths as absolutes.


Reply to this email directly or view it on GitHub<
https://github.com/asciidoctor/asciidoctor-maven-plugin/issues/45#issuecomment-17946669>

.

Jason Porter
http://en.gravatar.com/lightguardjp


Reply to this email directly or view it on GitHubhttps://github.com//issues/45#issuecomment-17947095
.

Enviat amb Gmail Mobile

@LightGuard
Copy link
Member

Well, if windows isn't honoring '.' and prepending the path to the project won't work either, how are we supposed to fixt this?

@lordofthejars
Copy link
Member

it is an strange behaviour because it only happens in Windows :S, do you think can be something related with Ruby?

@rdebusscher
Copy link
Author

Have a look at my comment I made earlier.

If we pass anything which isn't starting with '/' as OutputDirectory to the Ruby code, then it is prepended in Ruby (code of Dan Allen ??).

So I think this should work:

  • Take absolutePath() from File instance
  • Check if second character is : (I think this will not conflict with Linux, something like /:path/to/something isn't valid), Or check is we are on Windows
  • If so, pass only the path from the 3th character on to the Ruby code.

probably it needs to be fixed in the asciidoctor-java-integration code

@LightGuard
Copy link
Member

I'm wondering if this code needs to be changed in the java-integration
library so all other instances running on windows don't need to make the
same fixes.

On Wed, May 15, 2013 at 10:35 AM, Rudy De Busscher <notifications@github.com

wrote:

Have a look at my comment I made earlier.

If we pass anything which isn't starting with '/' as OutputDirectory to
the Ruby code, then it is prepended in Ruby (code of Dan Allen ??).

So I think this should work:

  • Take absolutePath() from File instance
  • Check if second character is : (I think this will not conflict with
    Linux, something like /:path/to/something isn't valid), Or check is we are
    on Windows
  • If so, pass only the path from the 3th character on to the Ruby code.


Reply to this email directly or view it on GitHubhttps://github.com//issues/45#issuecomment-17950307
.

Jason Porter
http://en.gravatar.com/lightguardjp

@lordofthejars
Copy link
Member

so you think that we can change toDir (and toFile because it happens too) attribute to receive an String instead of File, and then check the : character and passing from third. Right?

@rdebusscher
Copy link
Author

Changes in the method org.asciidoctor.OptionsBuilder#toDir(File) . It would leave the parameters of type File so that you don't need to check if the String is a valid directory.

And same for toFile(File)

@lordofthejars
Copy link
Member

ok now I understand what you meaning, sorry, ok then I suggest to close this issue and open one in asciidoctor-java-integration

@LightGuard
Copy link
Member

Opening in asciidoctor-java-integration

@lordofthejars
Copy link
Member

cool, can we remove support for Windows? 😆

@rdebusscher
Copy link
Author

Tested today (sorry for the delay) with 0.1.3.1 version and works as expected now.

Thx

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

3 participants