cordova-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Tobias Bocanegra (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (CB-11387) Relative plugin resolution does not work when cordova is executed as sub process
Date Wed, 08 Jun 2016 02:36:20 GMT

    [ https://issues.apache.org/jira/browse/CB-11387?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15319878#comment-15319878
] 

Tobias Bocanegra commented on CB-11387:
---------------------------------------

the problem lies in the way how the PWD is resolved. in {{utils.cdProjectRoot()}} \[0\] it
does:

{code}
    if (!origCwd) {
        origCwd = process.env.PWD || process.cwd();
    }
{code}

but the {{process.env.PWD}} does not reflect the CWD of the current process. This is a problem
when invoking a process via java (see \[1\]). It does not set the process.env.PWD.

the following java test illustrates this:

{code}
import java.io.File;
import sun.misc.IOUtils;

public class test {
    public static void main(String[]args) throws Exception {

        System.console().printf("Executing Node Script in '/'\n");
        String[] cmd = {
                "/data/nvm/versions/node/v4.2.6/bin/node",
                "-e",
                "console.log('pwd: %s, cwd: %s', process.env.PWD, process.cwd());"
        };
        Process p = Runtime.getRuntime().exec(cmd, null, new File("/").getCanonicalFile());
        p.waitFor();
        byte[] out = IOUtils.readFully(p.getInputStream(), -1, false);
        System.console().writer().write(new String(out));
        out = IOUtils.readFully(p.getErrorStream(), -1, false);
        System.console().writer().write(new String(out));
        System.console().flush();
        System.console().printf("done\n");
    }
}
{code}

When executing this in my home i get:

{noformat}
$ java -cp . test
Executing Node Script in '/'
pwd: /Users/tripod, cwd: /
done
{noformat}

\[0\] https://github.com/apache/cordova-lib/blob/c7f8b8c6e02ac7e5bd7b2ce5937b47dfcbb94e5f/cordova-lib/src/cordova/util.js#L131
\[1\] https://docs.oracle.com/javase/7/docs/api/java/lang/Runtime.html#exec(java.lang.String[],%20java.lang.String[],%20java.io.File)

> Relative plugin resolution does not work when cordova is executed as sub process
> --------------------------------------------------------------------------------
>
>                 Key: CB-11387
>                 URL: https://issues.apache.org/jira/browse/CB-11387
>             Project: Apache Cordova
>          Issue Type: Bug
>          Components: CordovaLib
>    Affects Versions: 6.2.0
>            Reporter: Tobias Bocanegra
>            Assignee: Tobias Bocanegra
>         Attachments: CB-11387-Example.zip
>
>
> (this used to work in 6.1.1)
> if {{cordova platform add}} is invoked as subprocess (for example in an ant-script),
the plugin spec resolution for relative plugins doesn't work.
> for example:
> {noformat}
>   <plugin name="cordova-testplugin" spec="./src/testplugin" />
> {noformat}
> See the attached script. when running with ant it shows:
> {noformat}
> $ ant test
> Buildfile: /Users/tripod/tmp/testfail/foo/build.xml
> test:
>      [exec] /Users/tripod/tmp/testfail/foo/testdir
>    [delete] Deleting directory /Users/tripod/tmp/testfail/foo/testdir/platforms
>    [delete] Deleting directory /Users/tripod/tmp/testfail/foo/testdir/plugins
>      [exec] Adding ios project...
>      [exec] iOS project created with cordova-ios@4.1.1
>      [exec] Discovered plugin "cordova-plugin-whitelist" in config.xml. Adding it to
the project
>      [exec] Fetching plugin "cordova-plugin-whitelist@1" via npm
>      [exec] Installing "cordova-plugin-whitelist" for ios
>      [exec] Discovered plugin "cordova-testplugin" in config.xml. Adding it to the project
>      [exec] Failed to restore plugin "cordova-testplugin" from config.xml. You might
need to try adding it again. Error: Error: Invalid package.json
> {noformat}
> please note, that ant sets the pwd correctly.
> when running from command line:
> {noformat}
> $ cd testdir; cordova platform add ios
> Adding ios project...
> iOS project created with cordova-ios@4.1.1
> Discovered plugin "cordova-plugin-whitelist" in config.xml. Adding it to the project
> Fetching plugin "cordova-plugin-whitelist@1" via npm
> Installing "cordova-plugin-whitelist" for ios
> Discovered plugin "cordova-testplugin" in config.xml. Adding it to the project
> Installing "cordova-testplugin" for ios
> {noformat}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


Mime
View raw message