dtw52353 2017-12-30 13:47
浏览 151
已采纳

SASS编译器无法从exec运行

In a CentOS container, I am trying to get the SASS to execute from PHP's exec(). SASS is executable, I can execute the command successfully from inside the container manually, but not from the PHP.

Command I am trying is:

PHP

$command = '/usr/local/bin/sass ' . $webFolderPath . '/styles/style_303.scss' . ' ' . $webFolderPath . '/styles/style_303.css';
$command .= " 2>&1";
echo $command;
exec($command, $output, $return);

Translates to:

/usr/local/bin/sass /var/www/html/portal/web/styles/style_303.scss /var/www/html/portal/web/styles/style_303.css 2>&1

I get the following error.

/usr/share/rubygems/rubygems/path_support.rb:68:in `path=': undefined method `+' for nil:NilClass (NoMethodError)
    from /usr/share/rubygems/rubygems/path_support.rb:30:in `initialize'
    from /usr/share/rubygems/rubygems.rb:357:in `new'
    from /usr/share/rubygems/rubygems.rb:357:in `paths'
    from /usr/share/rubygems/rubygems.rb:379:in `path'
    from /usr/share/rubygems/rubygems/specification.rb:794:in `dirs'
    from /usr/share/rubygems/rubygems/specification.rb:658:in `each_normal'
    from /usr/share/rubygems/rubygems/specification.rb:669:in `_all'
    from /usr/share/rubygems/rubygems/specification.rb:822:in `each'
    from /usr/share/rubygems/rubygems/specification.rb:864:in `find'
    from /usr/share/rubygems/rubygems/specification.rb:864:in `find_inactive_by_path'
    from /usr/share/rubygems/rubygems.rb:175:in `try_activate'
    from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:132:in `rescue in require'
    from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:144:in `require'
    from <internal:abrt_prelude>:2:in `<compiled>'

Versions:

Sass: 3.5.4 (Bleeding Edge)

Ruby: 2.0.0p648 (2015-12-16) [x86_64-linux]

Gem: 2.0.14.1

CentOS: 7

Any idea, if I am missing something?

  • 写回答

2条回答 默认 最新

  • dqpd4268 2017-12-30 16:41
    关注

    Ok, I manage to figure the problem out. The sass requires a home directory to operate correctly. If you are executing PHP as a system user, which in my case it was, it does not have a home directory, that is why it failed.

    On Linux, you can use mkhomedir_helper [user] to create a home directory. Once you have created a home directory, sass will start to work.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 shape_predictor_68_face_landmarks.dat
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料
  • ¥15 使用R语言marginaleffects包进行边际效应图绘制