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

플러그인 설치시 COMPOSER_HOME 에러 발생 #1051

Closed
darron1217 opened this issue Oct 15, 2019 · 6 comments
Labels

Comments

@darron1217
Copy link

@darron1217 darron1217 commented Oct 15, 2019

XE버전 3.0.5버전
우분투 18.04
php 7.3

PHP Built-In 웹서버 사용중인데
~/.profile에 COMPOSER_HOME 환경변수 추가하고 source ~/.profile 명령도 실행한 후에 다시 php서버 구동시켜도 안됩니다.
환경변수를 설정하는 페이지가 있다고 나와있는데 settings/setting 에 들어가도 설정항목이 안보입니다.

<warning>
Information of the plugin that should be installed:</warning>
  xero_commerce - xpressengine-plugin/xero_commerce:1.2.0

<warning>Clears the cache before the operation run.</warning>
Cache cleared successfully. XE cache has also been cleared.


<warning>Composer update command is running.. It may take up to a few minutes.</warning>
 composer update --with-dependencies xpressengine-plugin/xero_commerce
<warning> Checking file permission: </warning>
 /workspace/xe3/storage/app/composer.plugins.json - passed
 /workspace/xe3/storage/app/operations.json - passed
 /workspace/xe3/composer.lock - passed
 /workspace/xe3/plugins/ - passed
 /workspace/xe3/vendor/ - passed
 /workspace/xe3/vendor/composer/installed.json - passed

<warning> Checking COMPOSER_HOME environment variable: </warning>
[2019-10-15 10:25:10] production.ERROR: COMPOSER_HOME environment variable must be set for composer to run correctly. set the variable to http://xe3-jxnzv.run.goorm.io/settings/setting {"exception":"[object] (Exception(code: 0): COMPOSER_HOME environment variable must be set for composer to run correctly. set the variable to http://xe3-jxnzv.run.goorm.io/settings/setting at /workspace/xe3/app/Console/Commands/ComposerRunTrait.php:111)
[stacktrace]
#0 /workspace/xe3/app/Console/Commands/ComposerRunTrait.php(78): App\\Console\\Commands\\ShouldOperation->checkComposerHome()
#1 /workspace/xe3/app/Console/Commands/PluginCommand.php(148): App\\Console\\Commands\\ShouldOperation->prepareComposer()
#2 /workspace/xe3/app/Console/Commands/PluginInstall.php(83): App\\Console\\Commands\\PluginCommand->composerUpdate(Array)
#3 [internal function]: App\\Console\\Commands\\PluginInstall->App\\Console\\Commands\\{closure}(Object(Xpressengine\\Foundation\\Operator))
#4 /workspace/xe3/app/Console/Commands/ShouldOperation.php(112): call_user_func(Object(Closure), Object(Xpressengine\\Foundation\\Operator))
#5 /workspace/xe3/app/Console/Commands/ShouldOperation.php(165): App\\Console\\Commands\\ShouldOperation->start('plugin', Object(Closure), Object(Closure))
#6 /workspace/xe3/app/Console/Commands/PluginInstall.php(90): App\\Console\\Commands\\ShouldOperation->startPlugin(Object(Closure), Object(Closure))
#7 [internal function]: App\\Console\\Commands\\PluginInstall->handle()
#8 /workspace/xe3/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(29): call_user_func_array(Array, Array)
#9 /workspace/xe3/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(87): Illuminate\\Container\\BoundMethod::Illuminate\\Container\\{closure}()
#10 /workspace/xe3/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(31): Illuminate\\Container\\BoundMethod::callBoundMethod(Object(Xpressengine\\Foundation\\Application), Array, Object(Closure))
#11 /workspace/xe3/vendor/laravel/framework/src/Illuminate/Container/Container.php(549): Illuminate\\Container\\BoundMethod::call(Object(Xpressengine\\Foundation\\Application), Array, Array, NULL)
#12 /workspace/xe3/vendor/laravel/framework/src/Illuminate/Console/Command.php(183): Illuminate\\Container\\Container->call(Array)
#13 /workspace/xe3/vendor/symfony/console/Command/Command.php(255): Illuminate\\Console\\Command->execute(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Illuminate\\Console\\OutputStyle))
#14 /workspace/xe3/vendor/laravel/framework/src/Illuminate/Console/Command.php(170): Symfony\\Component\\Console\\Command\\Command->run(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Illuminate\\Console\\OutputStyle))
#15 /workspace/xe3/app/Console/Commands/ShouldOperation.php(82): Illuminate\\Console\\Command->run(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(App\\Console\\MultipleOutput))
#16 /workspace/xe3/app/Console/Commands/PluginCommand.php(75): App\\Console\\Commands\\ShouldOperation->run(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(App\\Console\\MultipleOutput))
#17 /workspace/xe3/vendor/symfony/console/Application.php(963): App\\Console\\Commands\\PluginCommand->run(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#18 /workspace/xe3/vendor/symfony/console/Application.php(254): Symfony\\Component\\Console\\Application->doRunCommand(Object(App\\Console\\Commands\\PluginInstall), Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#19 /workspace/xe3/vendor/symfony/console/Application.php(147): Symfony\\Component\\Console\\Application->doRun(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#20 /workspace/xe3/vendor/laravel/framework/src/Illuminate/Console/Application.php(88): Symfony\\Component\\Console\\Application->run(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#21 /workspace/xe3/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(121): Illuminate\\Console\\Application->run(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#22 /workspace/xe3/app/Console/Kernel.php(126): Illuminate\\Foundation\\Console\\Kernel->handle(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#23 /workspace/xe3/artisan(45): App\\Console\\Kernel->handle(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#24 {main}
"} 

@darron1217

This comment has been minimized.

Copy link
Author

@darron1217 darron1217 commented Oct 15, 2019

blade에서는 getenv('HOME') 가 정상적으로 출력되는데, xe3/app/Console/Commands/ComposerRunTrait.php 에서는 getenv('HOME')가 빈채로 출력되어 설정화면에도 안나오고 있는 상황입니다.
같은 getenv인데 다른 결과가 나오는 이유는 무엇인지 모르겠습니다

@darron1217

This comment has been minimized.

Copy link
Author

@darron1217 darron1217 commented Oct 15, 2019

.env 파일을 만들고 거기에 COMPOSER_HOME을 추가하니 작동하네요
XE3에서는 .env파일을 안쓰는걸로 알고있는데 더 나은 해결방안이 있을까요?

@Kazto-lsk

This comment has been minimized.

Copy link

@Kazto-lsk Kazto-lsk commented Oct 15, 2019

안녕하세요,
해당 문제는 COMPOSER_HOME environment variable must be set for composer to run correctly 를 확인하는 경우, 에 해당 하는 문제인 것 같습니다.

https://www.xpressengine.io/help_board?category_item_id=47&help_board_id=7b890eb7-2678-4d34-9679-8c05d8a0678d 링크에서 바로 해당 문제를 해결하실 수 있으며, 요약해 드리자면 아래와 같습니다.

관리자 사이트에서 설정 > 기본설정 > Composer 홈 디렉토리 항목에서 기본 XE3의 컴포저 경로를 입력하거나
별도로 설치한 Composer가 있는 경우 해당 디렉토리 항목을 입력 후 재 시도 해보시기 바랍니다.

만약 별도로 설치한 Composer가 없는 경우 /XE설치경로/composer.phar가 됩니다.

QnA에 답변과 동일한 내용이지만, 이슈 해결을 위해 댓글 남겨드립니다.

@darron1217

This comment has been minimized.

Copy link
Author

@darron1217 darron1217 commented Oct 15, 2019

@Kazto-lsk

Composer도 설치되어있고, COMPOSER_HOME에러가 나는 상황인데 설정페이지에는 composer_home 설정항목이 보이지 않는 문제입니다.

아래 blade 코드를 보시면 @if(!getenv('COMPOSER_HOME') && !getenv('HOME')) 이 조건에 맞다면 composer_home설정항목이 보이게 되어있는데, 여기서는 getenv('HOME') 이 환경변수가 있기때문에 composer_home설정항목이 보이지 않습니다(사진).

@if(!getenv('COMPOSER_HOME') && !getenv('HOME'))
<div class="col-sm-6">
<div class="form-group">
<label>{{ xe_trans('xe::site')}} {{ xe_trans('xe::composerHomeDir') }}</label> <small>{{ xe_trans('xe::descComposerHomeDir') }}</small>
{{ uio('formText', ['name'=>'composer_home', 'value'=>old('composer_home', $pluginConfig->get('composer_home'))]) }}
</div>
</div>
@endif

image

그런데 아래 코드에서는 (플러그인 설치시 실행되는 코드입니다) getenv('HOME') 이 환경변수가 출력되지 않아 에러가 발생합니다.

if (!$home) {
$home = getenv('HOME');
if (!$home) {
throw new \Exception(
"COMPOSER_HOME environment variable must be set for composer to run correctly. set the variable to " . route('settings.setting.edit')
);
}
}

blade에서의 환경변수와 console command 환경에서의 환경변수가 달라서 문제가 발생하는 것으로 추정되는데 정확한 원인을 모르겠습니다.

@darron1217

This comment has been minimized.

Copy link
Author

@darron1217 darron1217 commented Oct 15, 2019

참고로 서버환경은 PHP Built-In 서버를 사용하였습니다. 이것과 관련있을지도 모르겠습니다.
php -S 0.0.0.0:80 -t /workspace/xe3

@bnu

This comment has been minimized.

Copy link
Member

@bnu bnu commented Oct 15, 2019

해당 입력 필드를 가리지 말고 value를 보여주는 것으로 변경하고,
환경 변수 검사 부분의 보완 필요(getenv('HOME') ???).
@jhyeon1010 @woongbin

@bnu bnu added the type/bug label Oct 15, 2019
jhyeon1010 added a commit that referenced this issue Oct 22, 2019
@jhyeon1010 jhyeon1010 closed this Oct 22, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.