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

Setting plantuml.jar has no effect #147

Closed
RedX2501 opened this issue Sep 22, 2018 · 12 comments
Closed

Setting plantuml.jar has no effect #147

RedX2501 opened this issue Sep 22, 2018 · 12 comments

Comments

@RedX2501
Copy link

RedX2501 commented Sep 22, 2018

Using

@startuml
version
@enduml

I can see that the version i have set in settings.json is not picked up:

{
"plantuml.jar": "${workspaceFolder}/.vscode/plantuml.1.2018.10.jar"
}

It seems it does work but a full path must be specified.

It would be nice if the variable ${workspaceFolder} could be used so the settings file is agnostic of the PC it is running on. Or event if relative paths to the workspace could be given.

Plugin version: 2.9.0

qjebbs added a commit that referenced this issue Sep 25, 2018
@qjebbs
Copy link
Owner

qjebbs commented Sep 25, 2018

You should be able to use

{
    "plantuml.jar": "${workspaceFolder}/.vscode/plantuml.1.2018.10.jar"
}

or

{
    "plantuml.jar": ".vscode/plantuml.1.2018.10.jar"
}

with next release.

@qjebbs qjebbs closed this as completed Sep 29, 2018
@RedX2501
Copy link
Author

I'm still having troubles with this in 2.10.6

Now I added some debug code in config.js:

let jar = this.read('jar', uri, (folderUri, value) => {
                if (!value)
                    return "";
                if (!path.isAbsolute(value))
                    value = path.join(folderUri.fsPath, value);
                return value;
            });
            console.log(jar);
            let intJar = path.join(common_1.extensionPath, "plantuml.jar");
            console.log(intJar);
            if (!jar) {
                jar = intJar;
            }
            else {
                if (!fs.existsSync(jar)) {
                    vscode.window.showWarningMessage(common_1.localize(19, null));
                    jar = intJar;
                }
            }
            this._jar[folderPath] = jar;
            return jar;

I'm always getting the cannot resolve plantuml.jar setting message (Id 19).
What I see in the console is the unresolved ${workspaceFolder} variable in the file I provided.

@qjebbs
Copy link
Owner

qjebbs commented Mar 14, 2019

My fault that I removed the eval feature by this commit: 7bd077d
because it brings unwanted behavior to windows paths.

But the following should still work:

{
    "plantuml.jar": ".vscode/plantuml.1.2018.10.jar"
}

Can you try it?

@RedX2501
Copy link
Author

RedX2501 commented Mar 14, 2019

I'm trying to use tools/plantuml.1.2018.10.jar and it does not. Because path.isAbsolute seems to be returning true and It seems that on the call to jar(uri) the uri passed is null thus the workspaceFolder is not being prepended as folderUri is null.

In the debug window I see the path as entered without the workspace folder prepended.

@qjebbs
Copy link
Owner

qjebbs commented Mar 14, 2019

  1. You have to open the folder, folderUri won't be null then.
  2. make sure the relative path is correct, becuase:
if (!fs.existsSync(jar)) {
                    vscode.window.showWarningMessage(localize(19, null));
                    jar = intJar;
                }

I test a relative jar path works as expected here:

image

@RedX2501
Copy link
Author

RedX2501 commented Mar 14, 2019

I'm opening a folder with a .vscode directory in it.

Image

I have added more debug info.

@qjebbs
Copy link
Owner

qjebbs commented Mar 14, 2019

@RedX2501 Doesn't see anything..

Project
|__.vscode
   |__settings.json
|__tools
   |__plantuml.jar
|__src
   |__diagrams.puml

Make the following setting in workspace setting (Project/.vscode/settings.json). Edit in user setting also do the job, but not recommended, which means all projects use their own jar in tools folder.

{
    "plantuml.jar": "tools/plantuml.jar",
}

Should work as expected.

@RedX2501
Copy link
Author

@qjebbs I was having problems uploading. It should work now.

@qjebbs
Copy link
Owner

qjebbs commented Mar 14, 2019

OK, good to hear..

@RedX2501
Copy link
Author

I mean the image should work, the problem is still there.

@RedX2501
Copy link
Author

Ok, I think i see know what is going on.

When I start it will try to get the config for Uri null, which results in folderPath being empty. So a config is cached for the empty folderPath which does not find the jar file because it cannot resolve the relative path.

When i then press 'alt+d' to see the preview for the file it will now try with a proper uri and the cache will not have the entry for the new folderPath, now it will try to resolve and it will work.

@qjebbs
Copy link
Owner

qjebbs commented Mar 14, 2019

@RedX2501 I see, it's a false alarm, if you preview or export, your setting should have been applied. I'll fix it in next release.

qjebbs added a commit that referenced this issue Mar 14, 2019
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