GrumPHP and php-cs-fixer on WSL using wrong version - php-cs-fixer

I'm trying to get GrumPHP to work with a small Laravel 9 project but php-cs-fixer is being pulled from the wrong location and I can't seem to find how to change this.
Error from GrumPHP:
phpcsfixer
==========
PHP needs to be a minimum version of PHP 7.1.0 and maximum version of PHP 7.4.*.
You can fix errors by running the following command:
'/windir/f/wamp64/vendor/bin//php-cs-fixer' '--config=./home/testuser/php-cs-config.php_cs' '--verbose' 'fix'
Seems like an easy fix, so I updated php-cs-fixer and followed the upgrade guide to get to v3. (currently sitting on 3.10). But I can also see that '/windir/f/wamp64/vendor/bin//php-cs-fixer' is not the correct directory for php-cs-fixer, the actual bin folder is located in WSL not the windows directory so I included a GRUMPHP_BIN_DIR in the grumphp yaml but still no luck.
grumphp.yml
grumphp:
environment:
variables:
GRUMPHP_PROJECT_DIR: "."
GRUMPHP_BIN_DIR: "./home/testuser/tools/vendor/bin/"
paths:
- './home/plustime/tools'
tasks:
phpcsfixer:
config: "./home/testuser/php-cs-config.php_cs"
allow_risky: ~
cache_file: ~
rules: []
using_cache: ~
config_contains_finder: true
verbose: true
diff: false
triggered_by: ['php']
I can't seem to find much about this or anything in the docs, so any help would be appreciated.

This ended up coming down to altering how WSL constructs the environment. To get around WSL building windows paths into the Linux distribution.
The answer was found here:
How to remove the Win10's PATH from WSL
Quick run down:
On the WSL instance open the file /etc/wsl.conf with something like
sudo nano /etc/wsl.conf
Add the following lines to the bottom of the file,
[interop]
appendWindowsPath = false
Mine looked like this when it was finished:
# Enable extra metadata options by default
[automount]
enabled = true
root = /windir/
options = "metadata,umask=22,fmask=11"
mountFsTab = false
# Enable DNS – even though these are turned on by default, we'll specify here just to be explicit.
[network]
generateHosts = true
generateResolvConf = true
[interop]
appendWindowsPath = false
Then restart the WSL instance from your windows terminal and restart it.
wsl --shutdown
GrumPHP now using the correct php-cs-fixer.

Related

How to check or activate SyntaxHighlight_GeSHi?

During Mediawiki installation I checked the option for SyntaxHighlight, and it created a LocalSettings line,
wfLoadExtension( 'SyntaxHighlight_GeSHi' );
so, I am supposed that it was installed... But no examples for <source lang> tag is running. For instance the example of the Guide page, <syntaxhighlight lang="Python" line='line'> def quickSort(arr): ...</syntaxhighlight> and its variations (with <source> tag) are not working.
How to check if its alive?
How to activate or to complete the installation?
When installed on Linux, GeSHi requires the pygmentize binary to be marked executable (in the {wiki_installed_folder}/extensions/SyntaxHightlight_GeSHi folder) - by default that property might not be set.
Run "chmod +x pygmentize" to mark it executable - make sure to set the other read/write flags appropriately - to avoid any security issues.

Not able to change default download directory for chrome with selenium hub docker and ruby watir

After a few days of searching and experimenting with any of the solutions I could find online, I give up and want to get some help from the community.
Ruby gems (ruby 2.5.1):
watir 6.11.0
selenium-webdriver 3.4.1
Docker:
selenium/node-chrome-debug:3.14
selenium/hub:3.14
My ruby code:
prefs = {
download: {
prompt_for_download: false,
default_directory: download_directory
}
}
browser = Watir::Browser.new(:chrome, url: selenium_hub_url, options: {prefs: prefs})
Our set-up is:
Run a selenium/hub and a selenium/node-chrome-debug. Something that might be different is that we are mounting the /tmp of the base OS as /hosttmp/tmp in the node container
Make the selenium/node-chrome-debug talk to selenium/hub
Make the browser automation talk to the selenium/hub using the code provided above
The problem is that I was never able to set the default download directory. However, all other parts are working correctly. The VNC window shows the browser is working correctly despite the default download directory settings. It is always /home/seluser/Downloads
Things I have tried:
Other people's ideas such as different ways to specify the options and preferences. (e.g. using the Capabilities)
Docker security-related settings such as: --privileged --security-opt apparmor:unconfined --cap-add SYS_ADMIN
On the base OS, chmod 777 for the download_directory. The download_directory, for example, /tmp/tmp.123 on the base OS, which is mounted as /hosttmp/tmp/tmp.123 in the chrome node container, I could see it and make a few read/write operations in this folder inside the container or on the base OS
Tweaks about the interesting ruby symbol/string stuff when creating a Hash object.
Does anyone have more ideas about what could lead to this situation? What else I could try? And is there any log that I could refer to. There is no error or warning when running the code. Thanks in advance.
I'm using Java+Docker+Selenium+Chrome for automation test and also met similar issue with you. Please find my solutions below and try if it works for your case.
Don't set default download directory in the options, just leave "/home/seluser/Downloads" as it is.
When you start up the chrome node on docker, please add the parameter of volume that could transfer the downloaded files to the directory you want.
e.g. docker run -d -p 5900:5900 --link myhub:hub -v :/home/seluser/Downloads selenium/node-chrome-debug:3.14.0
In my case, the JDK environment and my test script is on Linux machine while the selenium webdriver & browser are all on docker, so once the file downloaded by browser it cannot saved directly on Linux machine, you have to mount the local directory with default directory on docker. Then you could find the file saved in the directory you want.
Thanks & Regards!
Jing
Did you define options = Selenium::WebDriver::Chrome::Options.new?
We use
options = Selenium::WebDriver::Chrome::Options.new
prefs = {
prompt_for_download: false,
default_directory: download_directory
}
options.add_preference(download: prefs)
and then you would want something like
browser = Watir::Browser.new(:chrome, url: selenium_hub_url, options: options)
But maybe the main problem is just that you are using
options: {prefs: prefs}
instead of
options: {download: prefs}
Okay, by digging into the source code of the Watir and Selenium-Webdriver, I think I know the 'root cause'.
I have created an issue since I am not sure if this is a bug or a 'feature' The issue
Also, I have a workaround for my case, in watir/capabilities.rb:
Change
#selenium_browser = browser == :remote || options[:url] ? :remote : browser
to
#selenium_browser = browser == :remote ? :remote : browser
This shouldn't be the final solution as it might not be a good idea. Will wait for what the Watir people say about this.

Messed up file contents in vagrant smb shared file

I decided to throw up a quick OpenCart installation today using the Homestead vagrant box with Hyper-V on my Windows 10 machine, and I've got my opencart folder mapped like this in Homestead.yml:
- map: D:\web\www\oc\oc-3.0.2.0
to: /home/vagrant/code/opencart
type: "smb"
All's well. The folder is synced in the vagrant VM as expected. But on trying to install OpenCart, I get this parse error:
PHP Parse error: syntax error, unexpected ''] == '' (T_CONSTANT_ENCAPSED_STRING) in /home/vagrant/code/opencart/upload/system/startup.php on line 93
Looking at lines 92-94 of that file on my host machine:
require_once(modification(DIR_SYSTEM . 'engine/event.php'));
require_once(modification(DIR_SYSTEM . 'engine/router.php'));
require_once(modification(DIR_SYSTEM . 'engine/loader.php'));
Looking at the same lines on the synced file in vagrant:
require_once(modification(DIR_SYSTEM . 'engine/event.php'));
requirePROTO'] == 'https' || !empty($_SERVER['HTTP_X_FORWARDED_SSL']) && $_SERVER['HTTP_X_FORWARDED_SSL'] == 'on') {
$_SERVER['HTTPS'] = true;
This code that's replaced the "require_once" code here appears earlier in this file. It's as if it's recopied over later code, making this file unusable. Here's the full file.
If I delete the lines that are copied or replace them with some other code, things appear find in the vagrant version. But if I only delete a couple of the lines, the rest still overwrite later code.
Does anyone have any idea what's causing this or how to resolve it?
So it turns out this had nothing to do with Homestead nor OpenCart. I pulled up another vagrant project I had and noticed similar problems with synced files.
I had recently installed Docker for Windows to play around with, so I decided to uninstall it and see if that would fix the problem. And it did.
So somewhere, somehow Vagrant and Docker aren't getting along on Windows 10. No idea where the exact problem is, though.

Issue with SaltStack

Recently I started taking an interest in Salt and begun doing a tutorial on it.I am currently working on a Mac and I having a hard time trying to start the vm[the minion] from my laptop[I am using Vagrant as an application to start the process]
The vagrant file for the vm contains these lines:
# salt-vagrant config
config.vm.provision :salt do |salt|
salt.run_highstate = true
salt.minion_config = "/etc/salt/minion"
salt.minion_key = "./minion1.pem"
salt.minion_pub = "./minion1.pub"
end
even though I wrote this it gets stuck at:
Calling state.highstate... (this may take a while)
Any ideas why?
One more thing.I seem to need to modify the top.sls file at the next step which is located in /srv/salt.Unfortunately I can not find the /srv file anywhere,why is that?is there a way to tell the master that the top file is somewhere else?
If you don't have a top.sls created, then you won't be able to run a hightstate like you have configured with the salt.run_highstate = true line.
If you don't have a /srv/salt/ directory created, then you can just create it yourself. Just make sure the user the salt-master is running as can read it.
The /srv/salt/ directory is the default location of what is known as the file_root. You can modify its location in the master config file /etc/salt/master and modify the file_roots config option.

symfony2 assetics yui compressor on windows (path syntax)

I'm trying to get assetics running with the yui compressor and, if this is running, sass. Right now, both don't work. When removing all filters from config.yml and the twig template, it works and php app/console assetic:dump does copy the css and js files.
Now I want to add the yui compressor and my config.yml looks like this:
assetic:
debug: %kernel.debug%
use_controller: false
filters:
yui_js:
jar: %kernel.root_dir%/Resources/java/yuicompressor-2.4.6.jar
Adding the filter to the template and running assetic:dump again ends in the following error (translation of message by me):
[RuntimeException]
The syntax for filename, directory name or drive name is wrong
I found an article telling me to specify the path to java.exe, so I add this to config.yml:
assetic:
..
java: C:/Program Files (x86)/Java/jre6/bin/java.exe
..
Now assetic:dump tells me:
[RuntimeException]
The COMMAND "C:/Program" is either written wrong or
I tried playing around with both variables (using \ or \ instead of /, adding single or double quotes, working with short alias Progra~1 or Progra~2) in the config, but I didn't get anywhere. The both errors comming up all the time. Maybe someone can point me in the right direction.
Ok, I figured it out. Man, this one was brutal.
Let's start with the easy stuff. A working version of the config.yml can look like this:
assetic:
debug: false
use_controller: false
java: C:\Program Files (x86)\Java\jre6\bin\java.exe
sass: C:\Program Files (x86)\Ruby192\bin\sass.bat
filters:
scss: ~
yui_js:
jar: %kernel.root_dir%\Resources\java\yuicompressor-2.4.6.jar
For some reason, assetic is always importing a whole directory for scss, so I had to make a combine.scss which imports the other scss files in the correct order.
And now it gets ugly, as one have to change the assetics core in order to get this working. The developers of assetic know this bug and I think it is fixed in some development trunk/branch but not the stable one.
The Assetic\Util\ProcessBuilder has to be changed on line 95
if (defined('PHP_WINDOWS_VERSION_MAJOR')) {
,line 103
$script .= ' '.implode(' ', array_map('escapeshellarg', $args));
and line 110
return new Process($script, $this->cwd, null, $this->stdin, $this->timeout, $options);
I hope this bug get fixed soon and till then anybody trying to get it working finds this thread... Took me like 8 hours of debuging, reading and trying different approaches.
Answer by Boo Nov 19 at 22:53 did work for me by changing everything he mentioned in Assetic\Util\ProcessBuilder (I ignored line 95 as it looks the same as in my file)
Now it works on windows. Thanks!
Just to confirm. Im using Symfony 2.0.7 and yuicompressor-2.4.7
For other users who use window server 2008 r2 :
Maybe you should change the C:\windows\Temp folder property to 777 (read/write) for the IIS user / or the machine's normal user
please unpack the ruby.7z from rubyinstaller.org , and go to C:\_ruby193\bin , in this unpack position you should exec the CMD prompt , type :
ruby -S gem install sass
so that you will get the sass.bat in that position
It's time to use Boo's best answer , and please notice that in symfony2 dev env maybe it's not necessary to change the use_controller to false (in the config.yml) , because there's another use_controller in the config_dev.yml (set to true) , and in routing_dev.yml there's also a _assetic router , they're perhaps associated.

Resources