find composer global install path as root

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
2
down vote

favorite












I have some php packages installed globally using php composer within a script



sudo -u me composer global require "phpmd/phpmd"


I want to find the path of these globally installed php packages. When I run which phpmd as user me I get the full path.




/home/me/.composer/vendor/bin/phpcs




However when I try and run the command as sudo I get nothing. I think this is because composer has been added globally and is in my user mes PATH while it is not present in sudo's PATH.



Instead I have tried



 path="$(sudo -u me which phpcs)"


But this also fails. However it succeeds for any program not installed through composer. How can I find the globally installed php packages through composer as sudo?



me's path



/home/me/.composer/vendor/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games


sudo (su's) path



/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games









share|improve this question























  • To troubleshoot, please show me's and root's path. That's probably where the problem is.
    – Julie Pelletier
    May 3 '16 at 16:33










  • updated the question @JuliePelletier
    – myol
    May 3 '16 at 16:42














up vote
2
down vote

favorite












I have some php packages installed globally using php composer within a script



sudo -u me composer global require "phpmd/phpmd"


I want to find the path of these globally installed php packages. When I run which phpmd as user me I get the full path.




/home/me/.composer/vendor/bin/phpcs




However when I try and run the command as sudo I get nothing. I think this is because composer has been added globally and is in my user mes PATH while it is not present in sudo's PATH.



Instead I have tried



 path="$(sudo -u me which phpcs)"


But this also fails. However it succeeds for any program not installed through composer. How can I find the globally installed php packages through composer as sudo?



me's path



/home/me/.composer/vendor/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games


sudo (su's) path



/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games









share|improve this question























  • To troubleshoot, please show me's and root's path. That's probably where the problem is.
    – Julie Pelletier
    May 3 '16 at 16:33










  • updated the question @JuliePelletier
    – myol
    May 3 '16 at 16:42












up vote
2
down vote

favorite









up vote
2
down vote

favorite











I have some php packages installed globally using php composer within a script



sudo -u me composer global require "phpmd/phpmd"


I want to find the path of these globally installed php packages. When I run which phpmd as user me I get the full path.




/home/me/.composer/vendor/bin/phpcs




However when I try and run the command as sudo I get nothing. I think this is because composer has been added globally and is in my user mes PATH while it is not present in sudo's PATH.



Instead I have tried



 path="$(sudo -u me which phpcs)"


But this also fails. However it succeeds for any program not installed through composer. How can I find the globally installed php packages through composer as sudo?



me's path



/home/me/.composer/vendor/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games


sudo (su's) path



/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games









share|improve this question















I have some php packages installed globally using php composer within a script



sudo -u me composer global require "phpmd/phpmd"


I want to find the path of these globally installed php packages. When I run which phpmd as user me I get the full path.




/home/me/.composer/vendor/bin/phpcs




However when I try and run the command as sudo I get nothing. I think this is because composer has been added globally and is in my user mes PATH while it is not present in sudo's PATH.



Instead I have tried



 path="$(sudo -u me which phpcs)"


But this also fails. However it succeeds for any program not installed through composer. How can I find the globally installed php packages through composer as sudo?



me's path



/home/me/.composer/vendor/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games


sudo (su's) path



/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games






bash php path






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited May 3 '16 at 16:42

























asked May 3 '16 at 16:18









myol

178111




178111











  • To troubleshoot, please show me's and root's path. That's probably where the problem is.
    – Julie Pelletier
    May 3 '16 at 16:33










  • updated the question @JuliePelletier
    – myol
    May 3 '16 at 16:42
















  • To troubleshoot, please show me's and root's path. That's probably where the problem is.
    – Julie Pelletier
    May 3 '16 at 16:33










  • updated the question @JuliePelletier
    – myol
    May 3 '16 at 16:42















To troubleshoot, please show me's and root's path. That's probably where the problem is.
– Julie Pelletier
May 3 '16 at 16:33




To troubleshoot, please show me's and root's path. That's probably where the problem is.
– Julie Pelletier
May 3 '16 at 16:33












updated the question @JuliePelletier
– myol
May 3 '16 at 16:42




updated the question @JuliePelletier
– myol
May 3 '16 at 16:42










2 Answers
2






active

oldest

votes

















up vote
0
down vote













The problem, as you can notice in the path difference, is that me's path includes /home/me/.composer/vendor/bin. Sudo does not inherit the user's environment.



You would need to manually import it. It's unclear why you'd want root to see a specific user's files in its path though.



To find a file, you can use the find command such as find /home -name FileName.






share|improve this answer




















  • Manually import the composer path?
    – myol
    May 3 '16 at 16:49

















up vote
0
down vote













Thanks to Julie's suggestion and some other answers on SO I came up with



 path="$(PATH=$PATH:/home/me/.composer/vendor/bin which phpcs)"


which works nicely






share|improve this answer




















    Your Answer







    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "106"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    convertImagesToLinks: false,
    noModals: false,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













     

    draft saved


    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f280846%2ffind-composer-global-install-path-as-root%23new-answer', 'question_page');

    );

    Post as a guest






























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    0
    down vote













    The problem, as you can notice in the path difference, is that me's path includes /home/me/.composer/vendor/bin. Sudo does not inherit the user's environment.



    You would need to manually import it. It's unclear why you'd want root to see a specific user's files in its path though.



    To find a file, you can use the find command such as find /home -name FileName.






    share|improve this answer




















    • Manually import the composer path?
      – myol
      May 3 '16 at 16:49














    up vote
    0
    down vote













    The problem, as you can notice in the path difference, is that me's path includes /home/me/.composer/vendor/bin. Sudo does not inherit the user's environment.



    You would need to manually import it. It's unclear why you'd want root to see a specific user's files in its path though.



    To find a file, you can use the find command such as find /home -name FileName.






    share|improve this answer




















    • Manually import the composer path?
      – myol
      May 3 '16 at 16:49












    up vote
    0
    down vote










    up vote
    0
    down vote









    The problem, as you can notice in the path difference, is that me's path includes /home/me/.composer/vendor/bin. Sudo does not inherit the user's environment.



    You would need to manually import it. It's unclear why you'd want root to see a specific user's files in its path though.



    To find a file, you can use the find command such as find /home -name FileName.






    share|improve this answer












    The problem, as you can notice in the path difference, is that me's path includes /home/me/.composer/vendor/bin. Sudo does not inherit the user's environment.



    You would need to manually import it. It's unclear why you'd want root to see a specific user's files in its path though.



    To find a file, you can use the find command such as find /home -name FileName.







    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered May 3 '16 at 16:47









    Julie Pelletier

    6,90211239




    6,90211239











    • Manually import the composer path?
      – myol
      May 3 '16 at 16:49
















    • Manually import the composer path?
      – myol
      May 3 '16 at 16:49















    Manually import the composer path?
    – myol
    May 3 '16 at 16:49




    Manually import the composer path?
    – myol
    May 3 '16 at 16:49












    up vote
    0
    down vote













    Thanks to Julie's suggestion and some other answers on SO I came up with



     path="$(PATH=$PATH:/home/me/.composer/vendor/bin which phpcs)"


    which works nicely






    share|improve this answer
























      up vote
      0
      down vote













      Thanks to Julie's suggestion and some other answers on SO I came up with



       path="$(PATH=$PATH:/home/me/.composer/vendor/bin which phpcs)"


      which works nicely






      share|improve this answer






















        up vote
        0
        down vote










        up vote
        0
        down vote









        Thanks to Julie's suggestion and some other answers on SO I came up with



         path="$(PATH=$PATH:/home/me/.composer/vendor/bin which phpcs)"


        which works nicely






        share|improve this answer












        Thanks to Julie's suggestion and some other answers on SO I came up with



         path="$(PATH=$PATH:/home/me/.composer/vendor/bin which phpcs)"


        which works nicely







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered May 3 '16 at 17:13









        myol

        178111




        178111



























             

            draft saved


            draft discarded















































             


            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f280846%2ffind-composer-global-install-path-as-root%23new-answer', 'question_page');

            );

            Post as a guest













































































            Popular posts from this blog

            How to check contact read email or not when send email to Individual?

            Displaying single band from multi-band raster using QGIS

            How many registers does an x86_64 CPU actually have?