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

Error when following the README instructions to install a new plugin via composer #160

Open
roukydesbois opened this issue Nov 29, 2022 · 3 comments

Comments

@roukydesbois
Copy link

Describe the bug

When trying to install a new plugin via composer following the instructions given in the README, an error is encountered.

Context

  • Hardware: VP bought online
  • YunoHost version: 11.0.10.2
  • I have access to my server: SSH and webadmin
  • Are you in a special context or did you perform some particular tweaking on your YunoHost instance?: Nope
  • Using, or trying to install package version/branch: N/A
  • If upgrading, current package version: N/A

Steps to reproduce

Connect to your server as root using SSH:

$ ssh [email protected]
$ sudo -i

Log in as the roundcube user - which owns the roundcube directory - and navigate in it:

su -s /bin/bash - roundcube

$ cd /var/www/roundcube

Install the plugin you want using composer - note that you have to specify kitist/html5_notifier and not only html5_notifier:

$ roundcube@ynh:~$ COMPOSER_HOME=./.composer php composer.phar require "kitist/html5_notifier"

Expected behavior

No error ;)

Logs

PHP Fatal error: Uncaught TypeError: json_decode() expects parameter 1 to be string, bool given in phar:///var/www/roundcube/composer.phar/src/Composer/Json/JsonFile.php:201
Stack trace:
#0 phar:///var/www/roundcube/composer.phar/src/Composer/Json/JsonFile.php(201): json_decode()
#1 phar:///var/www/roundcube/composer.phar/src/Composer/Factory.php(313): Composer\Json\JsonFile->validateSchema()
#2 phar:///var/www/roundcube/composer.phar/src/Composer/Factory.php(615): Composer\Factory->createComposer()
#3 phar:///var/www/roundcube/composer.phar/src/Composer/Console/Application.php(470): Composer\Factory::create()
#4 phar:///var/www/roundcube/composer.phar/src/Composer/Console/Application.php(412): Composer\Console\Application->getComposer()
#5 phar:///var/www/roundcube/composer.phar/src/Composer/Console/Application.php(353): Composer\Console\Application->hintCommonErrors()
#6 phar:///var/www/roundcube/composer.phar/vendor/symfony/console/Application.php(171): Composer\Console\Application->doRun()
#7 phar:///var/www/roundcube/com in phar:///var/www/roundcube/composer.phar/src/Composer/Json/JsonFile.php on line 201

Fatal error: Uncaught TypeError: json_decode() expects parameter 1 to be string, bool given in phar:///var/www/roundcube/composer.phar/src/Composer/Json/JsonFile.php:201
Stack trace:
#0 phar:///var/www/roundcube/composer.phar/src/Composer/Json/JsonFile.php(201): json_decode()
#1 phar:///var/www/roundcube/composer.phar/src/Composer/Factory.php(313): Composer\Json\JsonFile->validateSchema()
#2 phar:///var/www/roundcube/composer.phar/src/Composer/Factory.php(615): Composer\Factory->createComposer()
#3 phar:///var/www/roundcube/composer.phar/src/Composer/Console/Application.php(470): Composer\Factory::create()
#4 phar:///var/www/roundcube/composer.phar/src/Composer/Console/Application.php(412): Composer\Console\Application->getComposer()
#5 phar:///var/www/roundcube/composer.phar/src/Composer/Console/Application.php(353): Composer\Console\Application->hintCommonErrors()
#6 phar:///var/www/roundcube/composer.phar/vendor/symfony/console/Application.php(171): Composer\Console\Application->doRun()
#7 phar:///var/www/roundcube/com in phar:///var/www/roundcube/composer.phar/src/Composer/Json/JsonFile.php on line 201

*** Additional info
The app setting for PHP version is 7.4, php7.4-json is installed.

@roukydesbois
Copy link
Author

I'm not really comfortable with composer, so I don't know if the issue is on the app itself or in the way it's installed

@roukydesbois
Copy link
Author

OK - looking at the installation script, I think that because the composer is installed/executed during the install script, it's done using root - there are probably some composer-related files that don't have the correct permissions to be run using the roundcube user. Running the command as root works, I'll try to look what needs to be done to have it working with the roundcube user.

@ballinger
Copy link

this is still an issue.
ls -l total 3136 drwxr-x--- 2 roundcube www-data 4096 Aug 1 16:04 bin -rw-r----- 1 roundcube www-data 206050 Jul 23 2022 CHANGELOG.md -rw-r----- 1 root root 1213 Aug 1 16:04 composer.json -rw-r----- 1 roundcube www-data 1086 Jul 23 2022 composer.json-dist -rw-r--r-- 1 root root 122635 Aug 1 16:04 composer.lock_bak -rwxr-xr-x 1 root root 2719975 Aug 1 16:04 composer.phar drwxr-x--- 2 roundcube www-data 4096 Aug 5 20:53 config -rw-r----- 1 roundcube www-data 11368 Aug 1 16:04 index.php -rw-r----- 1 roundcube www-data 11199 Jul 23 2022 index.php.orig -rw-r----- 1 roundcube www-data 12661 Jul 23 2022 INSTALL drwxr-x--- 3 roundcube www-data 4096 Aug 1 16:04 installer -rw-r----- 1 roundcube www-data 4298 Jul 23 2022 jsdeps.json -rw-r----- 1 roundcube www-data 35147 Jul 23 2022 LICENSE drwxr-x--- 2 roundcube www-data 4096 Aug 1 16:07 logs drwxr-x--- 39 roundcube www-data 4096 Aug 1 16:04 plugins drwxr-x--- 8 roundcube www-data 4096 Aug 1 16:04 program drwxr-x--- 3 roundcube www-data 4096 Aug 1 16:04 public_html -rw-r----- 1 roundcube www-data 3853 Jul 23 2022 README.md -rw-r----- 1 roundcube www-data 967 Jul 23 2022 SECURITY.md drwxr-x--- 3 roundcube www-data 4096 Aug 1 16:04 skins drwxr-x--- 7 roundcube www-data 4096 Jul 23 2022 SQL drwxr-x--- 3 roundcube www-data 4096 Aug 1 16:04 temp -rw-r----- 1 roundcube www-data 4657 Jul 23 2022 UPGRADING drwxr-xr-x 21 root root 4096 Aug 1 16:04 vendor

`chown roundcube:www-data composer.*
COMPOSER_HOME=./.composer php composer.phar require "kitist/html5_notifier"
Cannot create cache directory /var/www/roundcube/./.composer/cache/repo/https---plugins.roundcube.net/, or directory is not writable. Proceeding without cache
Cannot create cache directory /var/www/roundcube/./.composer/cache/repo/https---repo.packagist.org/, or directory is not writable. Proceeding without cache
Info from https://repo.packagist.org: #StandWithUkraine
Using version ^0.6.4 for kitist/html5_notifier
./composer.json has been updated
Running composer update kitist/html5_notifier
Loading composer repositories with package information
Cannot create cache directory /var/www/roundcube/./.composer/cache/repo/https---plugins.roundcube.net/, or directory is not writable. Proceeding without cache
Cannot create cache directory /var/www/roundcube/./.composer/cache/repo/https---repo.packagist.org/, or directory is not writable. Proceeding without cache
Info from https://repo.packagist.org: #StandWithUkraine
Updating dependencies
Lock file operations: 1 install, 0 updates, 0 removals

  • Locking kitist/html5_notifier (v0.6.4)
    Writing lock file
    Installing dependencies from lock file (including require-dev)
    Package operations: 1 install, 0 updates, 0 removals
    Cannot create cache directory /var/www/roundcube/./.composer/cache/files/, or directory is not writable. Proceeding without cache
  • Downloading kitist/html5_notifier (v0.6.4)
  • Downloading kitist/html5_notifier (v0.6.4)
  • Downloading kitist/html5_notifier (v0.6.4)
  • Downloading kitist/html5_notifier (v0.6.4)
    Failed to download kitist/html5_notifier from dist: The "https://api.github.com/repos/stremlau/html5_notifier/zipball/c87b0be41384134dac2ad1f32c0c92f74547f049" file could not be written to /var/www/roundcube/vendor/composer/tmp-61f7caa97dbf0a60ec06dda5405dd2ee: failed to open stream: Permission denied
    Now trying to download from source
  • Syncing kitist/html5_notifier (v0.6.4) into cache
    Cloning failed using an ssh key for authentication, enter your GitHub credentials to access private repos
    `

could not finde the cache dir which also has permission issues. compose as root works

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