Only some drush commands working - xampp

I'm trying to get drush working on my ubuntu laptop because I want to try out the omega theme in Drupal, but some commands just don't work.
For example: drush en omega or drush omega-wizard
The Error I get: Drush was not able to start (bootstrap) the Drupal database.
or
Command pm-enable needs a higher bootstrap level to run - you will [error]
need to invoke drush from a more functional Drupal environment to run
this command.
I've read in other threads, that this has something to do with drush not being able to connect to my mysql database and that I should change 'localhost' to '127.0.0.1' in my settings.php.
I am using XAMPP and drush v 7.0-dev on my ubuntu 14.04.
I've also tried setting drush up on my windows 8.1 machine with xampp and ran into the same error.
Please help me, I ve been trying the whole weekend to set drush up and I am getting really desperate :(
The full error msg for 'omega-wizard'
The drush command 'omega-wizard' could not be found. Run drush [error]
cache-clear drush to clear the commandfile cache if you have
installed new extensions.
Drush was not able to start (bootstrap) the Drupal database. [error]
Hint: This may occur when Drush is trying to:
* bootstrap a site that has not been installed or does not have a
configured database. In this case you can select another site with a
working database setup by specifying the URI to use with the --uri
parameter on the command line. See drush topic docs-aliases for
details.
* connect the database through a socket. The socket file may be
wrong or the php-cli may have no access to it in a jailed shell. See
http://drupal.org/node/1428638 for details.
Drush was attempting to connect to:
Drupal version : 7.31
Site URI : http:// default
Database driver : mysql
Database hostname : localhost
Database port :
Database username : root
Database name : drupal1
PHP executable : /usr/bin/php
PHP configuration : /etc/php5/cli/php.ini
PHP OS : Linux
Drush version : 7.0-dev
Drush temp directory : /tmp
Drush configuration :
Drush alias files :
Drupal root : /home/trautmann/websites/mywebsite
Site path : sites/default

Wohoo I found a solution!
Thanks to Nathan I followed the error 'sh: 1: mysql: not found' provided by drush sql-cli and found this:
http://www.webbykat.com/2012/06/solving-sh-mysql-command-not-found-mamp-pro-2
which says, that my mysql command might not be mapped to the right location.
I adapted the solution for xampp by putting this line into my .bash_profile
export PATH=$PATH:/opt/lampp/bin
and boom! it worked :)
thanks again nathan
Edit:
Also, I found that drush needs to use the php executable in your xampp folder, you can set your PHP-path in your .bash_profile with
export DRUSH_PHP=/opt/lampp/bin/php

To see if drush is connecting to your site, you should go to the site's root directory for a single site install or to the site specific directory for a multisite install, then run "drush st" to see if your site is configured, this is what I get:
NY-MC-NB-NANDERSEN:muscleandfitness.com nandersen$ drush st
Drupal version : 7.31
Site URI : http://muscleandfitness.com
Default theme : garland
Administration theme : garland
PHP configuration : /Applications/MAMP/bin/php/php5.4.10/conf/php.ini
Drush version : 5.9
Drush configuration :
Drupal root : /Users/nandersen/dev/drupal7-core/docroot
Site path : sites/muscleandfitness.com
File directory path : sites/muscleandfitness.com/files
I'm running this from
/Users/nandersen/dev/drupal7-core/docroot/sites/muscleandfitness.com
on a multisite install
From what I'm seeing above, it looks like your drush isn't finding your site and connecting properly.
For example, if I'm not in the correct directory, I get this when I run "drush st"
NY-MC-NB-NANDERSEN:docroot nandersen$ drush st
Drupal version : 7.31
Default theme : garland
Administration theme : garland
PHP configuration : /Applications/MAMP/bin/php/php5.4.10/conf/php.ini
Drush version : 5.9
Drush configuration :
Drupal root : /Users/nandersen/dev/drupal7-core/docroot
To test if you are connected to the database, you can run the command "drush sql-cli" which will launch into the currently bootstrapped database.
To see if a command is available, such as "omega-wizard", you can just type "drush" then pipe it to grep then the search term, so "drush | grep wizard", this will output any command that has wizard in the help file. If I forget commands, this is how I see what drush commands are available. Since you can't enable omega, and the omega command aren't available, this is another sign that you probably are not connecting to the database properly.

For the Windows environment running XAMPP, I added C:\xampp\mysql\bin\ to the PATH environment variable so that mysql.exe can be found.

Turn on debug message when issuing drush command will give out more information about what is not working. In case of not be able to run mysql, the -d option will report that so you know the direction to fix the problem.
drush -d omega-wizard
...
Drush bootstrap phase : _drush_bootstrap_drupal_configuration() [0.1 [bootstrap]
sec, 4.48 MB]
sql-query: SELECT 1; [0.16 sec, 4.6 MB]
Executing: mysql --defaults-extra-file=/private/tmp/drush_aATUxP --database=drupal --host=localhost --silent < /private/tmp/drush_JBBjco
sh: mysql: command not found

Related

Using xdebug with drush command

I have two Drupal codebases. On the first, I can hit a specific breakpoint through both the browser and through a drush command. On the second, I can hit the breakpoint only through the browser. The drush command finishes successfully without hitting the breakpoint. I can't find any meaningful difference between the two installations.
Local development on Windows 10 home
Docker toolbox
DDEV v1.14.2
Composer version 1.10.5
IDE is VSCode, launch.json file is identical between the two
Drush Launcher not installed
The good one:
c:...\d8-04-28>ddev exec drush status
Drupal version : 8.8.5
Site URI : https://d8-04-28.ddev.site
DB driver : mysql
DB hostname : db
DB port : 3306
DB username : db
DB name : db
Database : Connected
Drupal bootstrap : Successful
Default theme : bartik
Admin theme : seven
PHP binary : /usr/bin/php7.3
PHP config : /etc/php/7.3/cli/php.ini
PHP OS : Linux
Drush script : /var/www/html/vendor/drush/drush/drush
Drush version : 10.2.2
Drush temp : /tmp
Drush configs : /var/www/html/vendor/drush/drush/drush.yml
/var/www/html/drush/drush.yml
Install profile : standard
Drupal root : /var/www/html/web
Site path : sites/default
Files, Public : sites/default/files
Files, Temp : /tmp
The bad one
c:...\d8-06-08>ddev exec drush status
Drupal version : 8.8.5
Site URI : https://d8-06-08.ddev.site
DB driver : mysql
DB hostname : db
DB port : 3306
DB username : db
DB name : db
Database : Connected
Drupal bootstrap : Successful
Default theme : bartik
Admin theme : seven
PHP binary : /usr/bin/php7.3
PHP config : /etc/php/7.3/cli/php.ini
PHP OS : Linux
Drush script : /usr/local/bin/drush
Drush version : 10.2.2
Drush temp : /tmp
Drush configs : /var/www/html/vendor/drush/drush/drush.yml
/var/www/html/drush/drush.yml
Install profile : standard
Drupal root : /var/www/html/web
Site path : sites/default
Files, Public : sites/default/files
Files, Temp : /tmp
On the bad one only, after turning on xdebug in ddev, the PHP config line in drush status changes to:
PHP config : /tmp/bApEy0
I'm pretty sure my debugging problem has to do with the drush script line in drush status, but I can't find anything to change that affects that line.
Any ideas to point me in the right direction?
I note that the first one shows "Drush script : /var/www/html/vendor/drush/drush/drush" and the second one "Drush script : /usr/local/bin/drush". But inside the container, /usr/local/bin/drush is "drush launcher". So there's definitely a difference in how this is happening.
When debugging drush (or any command line script), execute it the simplest way possible, which is inside the container, so ddev ssh and then run drush.
But be specific about what you're running, don't use the drush launcher in the container, run the site-installed drush by running /var/www/html/vendor/bin/drush - that way there aren't extra layers of scripts running extra layers of drush.
Nothing about drush or drush launcher on your host system would be relevant, because everything is happening inside the container.
Remember to ddev xdebug on before debugging.
Please review "PHPStorm and Command-Line Debugging" in the docs at https://ddev.readthedocs.io/en/latest/users/step-debugging/#step-debugging-with-ddev-and-xdebug and also Matt Glaman's excellent blog about xdebug over the command line
This is because
Drush Launcher, like Composer automatically disables Xdebug by default. -- https://github.com/drush-ops/drush-launcher#xdebug-compatibility
As the doc suggests, you can run DRUSH_ALLOW_XDEBUG=1 drush [command] to trigger xdebug,
or run ./vender/bin/drush [command] to trigger xdebug (without using the launcher)
or put DRUSH_ALLOW_XDEBUG=1 in your env variable, so normal drush [command] can also trigger xdebug. Here is an example

Behat + CircleCI Configuration for my drupal8 site

I am very new to drupal. I am using drupal8 with pantheon. I have created a site "ucfictious". I have created a local copy by using composer and drush. Everything went well and I configured behat tests which also went well. Now I am trying to configure CircleCI through github. I ran into so many errors and I couldn't solve my errors. Can anyone help me with the configuration of CircleCI? I am using Craychee's Work to build CircleCI and When I run I get the following error:
build/install.sh
Command config-import needs a higher bootstrap level to run - you [error]
will need to invoke drush from a more functional Drupal environment
to run this command.
The drush command 'config-import' could not be executed. [error]
Drush was not able to start (bootstrap) the Drupal database. [error]
Hint: This may occur when Drush is trying to:
* bootstrap a site that has not been installed or does not have a
configured database. In this case you can select another site with a
working database setup by specifying the URI to use with the --uri
parameter on the command line. See drush topic docs-aliases for
details.
Drupal Version: 8.2.5
Drush Version: 8.1.8
Php Vesion: 5.6
For Behat Configuration I followed Craychee's work: http://craychee.io/blog/2015/08/04/no-excuses-part4-testing/
Thanks.
Got it Working...My database is not populated properly.....by doing a sql-sync from the DEV environment (so it was a known-clean copy, i.e. not filled with testing junk) and then used mysqldump.

wp-cli: unable to run phpunit on MAMP

I'm following the plugin test setup/install instructions. I got wp scaffold plugin-tests my-plugin to run. But then at the next step when I try to run bash bin/install-wp-tests.sh wordpress_test root '' localhost latest I get the following error:
mysqladmin: connect to server at 'localhost' failed
error: 'Can't connect to MySQL server on 'localhost' (61)'
Check that mysqld is running on localhost and that the port is 3306.
You can check this by doing 'telnet localhost 3306'
My local Wordpress site is running with MAMP (which is working). I'm not sure if that's relevant for the install script since I think it's creating a temporary DB to run the tests... Does it matter if it uses the built-in OSX mysql or MAMP's MySQL?
Here's the output from wp --info
$ ./vendor/wp-cli/wp-cli/bin/wp --info
PHP binary: /Applications/MAMP/bin/php/php5.6.10/bin/php
PHP version: 5.6.10
php.ini used: /Applications/MAMP/bin/php/php5.6.10/conf/php.ini
WP-CLI root dir: /Applications/MAMP/htdocs/pipeline/wp-content/plugins/wp-github-pipeline/vendor/wp-cli/wp-cli
WP-CLI global config:
WP-CLI project config:
WP-CLI version: 0.19.2
Update 2
I figured out that originally MySQL wasn't installed... that's why I couldn't connect! But now it is. I ran the install script, and this works...
$ ./vendor/wp-cli/wp-cli/bin/wp db tables
wp_users
wp_usermeta
wp_posts
wp_comments
wp_links
wp_options
wp_postmeta
wp_terms
wp_term_taxonomy
wp_term_relationships
wp_commentmeta
But when I run phpunit I get this:
$ phpunit
PHP Warning: mysqli_real_connect(): (HY000/2002): No such file or directory in /private/tmp/wordpress/wp-includes/wp-db.php on line 1452
PHP Stack trace:
PHP 1. {main}() /private/tmp/wordpress-tests-lib/includes/install.php:0
PHP 2. require_once() /private/tmp/wordpress-tests-lib/includes/install.php:21
PHP 3. require_wp_db() /private/tmp/wordpress/wp-settings.php:79
PHP 4. wpdb->__construct() /private/tmp/wordpress/wp-includes/load.php:350
PHP 5. wpdb->db_connect() /private/tmp/wordpress/wp-includes/wp-db.php:649
PHP 6. mysqli_real_connect() /private/tmp/wordpress/wp-includes/wp-db.php:1452
Warning: mysqli_real_connect(): (HY000/2002): No such file or directory in /private/tmp/wordpress/wp-includes/wp-db.php on line 1452
Part of my problem is that I'm not clear on whether wp-cli should be running entirely on native (cli) PHP/Mysql, or MAMP's PHP/Mysql, or some combination of both.
Update 4
I'm pretty sure the final problem is that phpunit needs to be installed in MAMP, but I'm running it from OSX...
$which phpunit
/usr/bin/phpunit
Mentioned in this gist.
Update 6
It turns out you can no longer install phpunit using pear. So I added it as a composer dependency under require-dev, but when I run that version I get the same error!
$ ./vendor/phpunit/phpunit/phpunit
PHP Warning: mysqli_real_connect(): (HY000/1045): Access denied for user 'root'#'localhost' (using password: NO) in /private/tmp/wordpress/wp-includes/wp-db.php on line 1452
PHP Stack trace:
PHP 1. {main}() /private/tmp/wordpress-tests-lib/includes/install.php:0
PHP 2. require_once() /private/tmp/wordpress-tests-lib/includes/install.php:21
PHP 3. require_wp_db() /private/tmp/wordpress/wp-settings.php:79
PHP 4. wpdb->__construct() /private/tmp/wordpress/wp-includes/load.php:350
PHP 5. wpdb->db_connect() /private/tmp/wordpress/wp-includes/wp-db.php:649
PHP 6. mysqli_real_connect() /private/tmp/wordpress/wp-includes/wp-db.php:1452
Warning: mysqli_real_connect(): (HY000/1045): Access denied for user 'root'#'localhost' (using password: NO) in /private/tmp/wordpress/wp-includes/wp-db.php on line 1452
I even added it to my path to be sure...
$ which phpunit
/Applications/MAMP/htdocs/pipeline/wp-content/plugins/wp-github-pipeline/vendor/phpunit/phpunit/phpunit
Update 7
After reading the comments at the bottom of this blog post, I see that the install script was referencing the OSX version of mysqladmin. I'm not sure if this matters, but I prepended MAMPs version in the path, and re-ran the install script. It seems to install the Wordpress files in /tmp/ anyway. Same error when I run phpunit
If you are using MAMP, issue may be relevant to your MySQL Server settings. Make sure to check Allow network access option in MAMP settings:
Update 1
Create phpinfo.php file in your root directory (usually /Applications/MAMP/htdocs for MAMP). Paste the following content:
<?php phpinfo() ?>
Then check the Loaded Configuration File property. Open it using nano or other text editor in terminal. Then find and change this 3 propertiespdo_mysql.default_socket, mysql.default_socket, mysqli.default_socket to your socket file.
Referenced from http://maccrazy.com/lion-upgrade-killed-my-php-site-and-how-i-fixed-it
I finally got phpunit to run!!
I couldn't find this documented anywhere...
At some point during the installation process, Wordpress core files are installed in /tmp/wordpress/. That Wordpress installation has it's own wp-config.php file which had incorrect values. When I corrected those values to match the wp-config.php of my site, phpunit worked without problems!
I'm not sure how this happened, but my theory is that the first time I ran the install script with the wrong credentials. But later I corrected them (I re-ran the install script several times). But I think the install script didn't overwrite the original files.
+400 to #Nikita Zernov for so much help!
Normally if you ftp or telnet to localhost you'll get conection refused, if you want to fix the error change your httpd.conf to ServerName localhost
Also if you want to do remote login try enable remote login by going to
System Preferences -> Sharing -> Remote Login box (check it).
For MySQL Problem
Make sure ‘skip-networking’ is commented out in configuration file(in this case /opt/local/etc/mysql55/my.conf) or when starting mysql server, it does’t start with ‘–skip-networking’
In skip-networking mode, the mysql instance doesn’t “listen for TCP/IP connections at all. All interaction with mysqld must be made using named pipes or shared memory (on Windows) or Unix socket files (on Unix)” from MySql Docs
I hope it help.

Drush cannot connect to MySQL on MAMP?

Im trying to set Drush up for the first time. Im using Mamp and Mountain Lion. When I type 'drush' into the terminal I get a list of commands so it seems to be installed up OK.
Ive changed the default web directory folder in MAMP. I have many Drupal sites within folders within the web directory. So the url for one site is http://localhost:8888/omega/omegav3/ and another is http://localhost:8888/omega/omegav4/
By navigating to the site folder in the terminal I can then run a Drush command, however I get errors. When I download Views it does download the module to my sites/all/modules folder correctly, however it gives me some errors. When I try and enable the module it gives me more errors and doesn't enable the module.
unknown:omegav3 MYUSERNAME$ cd /Users/MYUSERNAME/Dropbox/sites/omega/omegav3
unknown:omegav3 MYUSERNAME$ drush dl views
PDO::__construct(): [2002] No such file or directory (trying to connect via [warning]
unix:///var/mysql/mysql.sock) environment.inc:523
Project views (7.x-3.7) downloaded to sites/all/modules/views. [success]
Project views contains 2 modules: views, views_ui.
unknown:omegav3 MYUSERNAME$
unknown:omegav3 MYUSERNAME$ drush en views
PDO::__construct(): [2002] No such file or directory (trying to connect via [warning]
unix:///var/mysql/mysql.sock) environment.inc:523
Command pm-enable needs a higher bootstrap level to run - you will need to invoke [error]
drush from a more functional Drupal environment to run this command.
The drush command 'en views' could not be executed. [error]
Drush was not able to start (bootstrap) the Drupal database. [error]
Hint: This may occur when Drush is trying to:
* bootstrap a site that has not been installed or does not have a configured
database. In this case you can select another site with a working database setup by
specifying the URI to use with the --uri parameter on the command line. See `drush
topic docs-aliases` for details.
* connect the database through a socket. The socket file may be wrong or the php-cli
may have no access to it in a jailed shell. See http://drupal.org/node/1428638 for
details.
Drush was attempting to connect to:
Drupal version : 7.23
Site URI : http://default
Database driver : mysql
Database username : root
Database name : omegav3
Default theme : garland
Administration theme : garland
PHP executable : /usr/bin/php
PHP configuration :
PHP OS : Darwin
Drush version : 6.1.0
Drush configuration :
Drush alias files :
Drupal root : /Users/MYUSERNAME/Dropbox/sites/omega/omegav3
Site path : sites/default
File directory path : sites/default/files
unknown:omegav3 MYUSERNAME$
It seems like an issue with Drush and MySQL but ive no idea how to fix this. Im very new to the command line and ive never installed anything like Drush before so im really struggling.
Lets start with saying that i am not familiar with Drush at all. But looking at this from a MAMP perspective i think i know what is going on here.
The line
PDO::__construct(): [2002] No such file or directory (trying to connect via [warning]
unix:///var/mysql/mysql.sock) environment.inc:523 says it all.
By default MAMP is creating the MySQL socket in /Applications/MAMP/tmp/mysql/mysql.sock as stated on the MAMP launch page. However Drush is expecting the socket at var/mysql/mysql.sock.
Well there are two ways to fix this.
Stop all MAMP servers. Edit the file /Applications/MAMP/bin/startMysql.sh,
change --socket=/Applications/MAMP/tmp/mysql/mysql.sock into --socket=/var/mysql/mysql.sock. And don't forget to edit stopMysql.sh as well. This tells MAMP to store the socket elsewhere the next time it boots up the Mysql server.
Create a symlink from /var/mysql/mysql.sock to /Applications/MAMP/tmp/mysql/mysql.sock see this post for more info on symlinks. MAMP will need to be running for you to do this, as the socket file is created dynamically.
Good luck!
I had the same issue - what solved it for me was changing the database host in settings.php from "localhost" to "127.0.0.1".
For me the mysql bin was not existant.
sudo ln -s /Applications/MAMP/Library/bin/mysql /usr/bin/mysql
Fixed it for me.
As an alternative to answer #1, I would recommend you change your command-line MySQL to use MAMP's - this makes sure when you mysql from the command line, that works too. Edit your ~/.bash_profile and add the following line:
alias mysql='/Applications/MAMP/Library/bin/mysql'
This worked for me
sudo mkdir /var/mysql
sudo ln -s /Applications/MAMP/tmp/mysql/mysql.sock /var/mysql/mysql.sock

How to enable all the modules installed on Magento using php

I was trying to disabling some modules not in used and somehow my admin crashed and now I don't see any option to bring all the modules output back. Is there any way to get all the modules enabled again via any php script
Thank you
If you disabled modules by the admin configuration page then a change needs to be made in the database. Enter this command by using phpMyAdmin or any other SQL tool you prefer:
UPDATE `core_config_data`
SET `value` = '0'
WHERE `path` LIKE 'advanced/modules_disable_output/%';
Yes there is a command line way of doing this:
First you go into the folder where your magento is installed:
cd /public_html (or whichever folder it is)
Grant the 'mage' user some basic rights:
chmod 530 mage
Now your could install using this user:
./mage install http://connect20.magentocommerce.com/community name_of_module
When you copy the name of the module from the magento web site it will be :
http://connect20.magentocommerce.com/community/name_of_module
make sure to replace the last forward slash with a space
http://connect20.magentocommerce.com/community name_of_module

Resources