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

Fresh install, artisan "Undefined index: driver" error #116

Closed
seanknox opened this issue Jan 14, 2014 · 21 comments
Closed

Fresh install, artisan "Undefined index: driver" error #116

seanknox opened this issue Jan 14, 2014 · 21 comments

Comments

@seanknox
Copy link

Cloned the repo, and upon running artisan (either manually or installing through composer), I receive this error:

$ php artisan app:install                                                   
{"error":{"type":"ErrorException","message":"Undefined index: driver","file":"\/Users\/sean\/src\/snipe-it\/vendor\/laravel\/framework\/src\/Illuminate\/Mail\/MailServiceProvider.php","line":87}}%

Any idea?

@snipe
Copy link
Owner

snipe commented Jan 14, 2014

Hi @seanknox - looks like you might have pulled down an older version of Laravel? I found this:
laravel/framework#700

What's your email config look like in whichever environment you're sung, like app/config/testing/mail.php or app/config/local/mail.php?

@seanknox
Copy link
Author

Hey @snipe. I tried updating laravel via composer update laravel/framework but still received that artisan error. Then just to be sure I was using the latest 4.0.x release:

  • I hardcoded the laravel/framework SHAs in composer.lock to ensure version 4.0.10, then
  • blew away vendor/laravel
  • re-ran composer install.

Unfortunately I'm still seeing that error. First time using composer/artisan, so please correct me if I'm misunderstanding anything.

Here's my app/config/local/mail.php—I've using both the template and copying mail.php as that framework issue suggested.

<?php

return array(

  /*
  |--------------------------------------------------------------------------
  | Mail Driver
  |--------------------------------------------------------------------------
  |
  | Laravel supports both SMTP and PHP's "mail" function as drivers for the
  | sending of e-mail. You may specify which one you're using throughout
  | your application here. By default, Laravel is setup for SMTP mail.
  |
  | Supported: "smtp", "mail", "sendmail"
  |
  */

  'driver' => 'local',

  /*
  |--------------------------------------------------------------------------
  | SMTP Host Address
  |--------------------------------------------------------------------------
  |
  | Here you may provide the host address of the SMTP server used by your
  | applications. A default option is provided that is compatible with
  | the Postmark mail service, which will provide reliable delivery.
  |
  */

  'host' => 'smtp.mailgun.org',

  /*
  |--------------------------------------------------------------------------
  | SMTP Host Port
  |--------------------------------------------------------------------------
  |
  | This is the SMTP port used by your application to delivery e-mails to
  | users of your application. Like the host we have set this value to
  | stay compatible with the Postmark e-mail application by default.
  |
  */

  'port' => 587,

  /*
  |--------------------------------------------------------------------------
  | Global "From" Address
  |--------------------------------------------------------------------------
  |
  | You may wish for all e-mails sent by your application to be sent from
  | the same address. Here, you may specify a name and address that is
  | used globally for all e-mails that are sent by your application.
  |
  */

  'from' => array('address' => 'blah@blah.com', 'name' => 'blah'),

  /*
  |--------------------------------------------------------------------------
  | E-Mail Encryption Protocol
  |--------------------------------------------------------------------------
  |
  | Here you may specify the encryption protocol that should be used when
  | the application send e-mail messages. A sensible default using the
  | transport layer security protocol should provide great security.
  |
  */

  'encryption' => 'tls',

  /*
  |--------------------------------------------------------------------------
  | SMTP Server Username
  |--------------------------------------------------------------------------
  |
  | If your SMTP server requires a username for authentication, you should
  | set it here. This will get used to authenticate with your server on
  | connection. You may also set the "password" value below this one.
  |
  */

  'username' => 'blah',

  /*
  |--------------------------------------------------------------------------
  | SMTP Server Password
  |--------------------------------------------------------------------------
  |
  | Here you may set the password required by your SMTP server to send out
  | messages from your application. This will be given to the server on
  | connection so that the application will be able to send messages.
  |
  */

  'password' => 'blah',

  /*
  |--------------------------------------------------------------------------
  | Sendmail System Path
  |--------------------------------------------------------------------------
  |
  | When using the "sendmail" driver to send e-mails, we will need to know
  | the path to where Sendmail lives on this server. A default path has
  | been provided here, which will work well on most of your systems.
  |
  */

  'sendmail' => '/usr/sbin/sendmail -bs',

  /*
  |--------------------------------------------------------------------------
  | Mail "Pretend"
  |--------------------------------------------------------------------------
  |
  | When this option is enabled, e-mail will not actually be sent over the
  | web and will instead be written to your application's logs files so
  | you may inspect the message. This is great for local development.
  |
  */

  'pretend' => false,

);

@snipe
Copy link
Owner

snipe commented Jan 14, 2014

Weird... I'm seeing this in a laravel-bootstrap issue as well, but it was corrected in a previous version: andrewelkins/Laravel-4-Bootstrap#8

Still looking into this - bear with me.

@snipe
Copy link
Owner

snipe commented Jan 14, 2014

You're sure your system thinks you're in the local environment?

bootstrap/start.php, around line 29:

$env = $app->detectEnvironment(array(

'local'         => array('http://*.dev', 'http://*.local', '*.local*', '127.0.0.1', 'localhost*'),
'staging'       => array('http://staging.yourserver.com'),
'production'    => array('http://www.yourserver.com')

));

Did you configure those so to match your local url?

@seanknox
Copy link
Author

My bootstrap/start.php looks like this:

$env = $app->detectEnvironment(array(

  'local'     => array('http://snipe-it.dev', '127.0.0.1', 'localhost*'),
  'staging'     => array('http://staging.yourserver.com'),
  'production'  => array('http://www.yourserver.com')
));

All of those in the local array resolve to my local computer. Anything look fishy there?

@snipe
Copy link
Owner

snipe commented Jan 14, 2014

Nope, if http://snipe-it.dev is the url you're using to access the application, it should be seeing it as local. Do me a favor and throw some garbage into app/config/local/mail.php, and re-run.

Like:

<?php
echo 'blah blah blah
exit;

(with the parse error there on purpose)

I'm looking to see if we get a different error, which might imply that it's not actually looking at app/config/local/mail.php for the config.

@seanknox
Copy link
Author

Put that in app/config/local/mail.php, still get the same "undefined index: driver" error. That seems to imply that my environment is not being detected as local, right? FWIW I don't have mail.php in the production or testing folders—just the example templates.

@snipe
Copy link
Owner

snipe commented Jan 14, 2014

That's helpful info, thank you! It does sorta feel like it's not grokking the app/config/local/mail.php, which is what I was trying to determine. Do you have mail.php in the main config dir (outside of the environmental dirs)? If so, let's try the same thing one by one in those.

@seanknox
Copy link
Author

Sure thing. The only mail.php I have is the one
`.app/config/local/mail.php'.

Could my PHP environment possible be setup in some non-standard way?

@snipe
Copy link
Owner

snipe commented Jan 14, 2014

It shouldn't be - we're not using any system environmental variables here, it's using only the hostname.

Can you take a look at your logs and see if there's anything useful in there? app/storage/logs

@seanknox
Copy link
Author

Unfortunately there's no log file anywhere in the repo.

@snipe
Copy link
Owner

snipe commented Jan 14, 2014

Excellent news! I can reproduce your error! Hold tight please while I investigate further.

@seanknox
Copy link
Author

🤘

@snipe
Copy link
Owner

snipe commented Jan 14, 2014

The good news is that this is definitely a bug. ("It's not you, it's me!") The bad news is that this is definitely a bug. :P I'll absolutely get to the bottom of it today though. What's your environment, just for my own reference?

@seanknox
Copy link
Author

I'm on OS X Mavericks, using GitHub's Boxen to manage PHP and other system dependencies. Since you can reproduce it I don't think it's Boxen (which installs some tools like PHP in non-standard locations—it's all in my path, but sometimes software that uses hardcoded locations for dependencies instead of sussing out where those dependencies are installed, and that causes problems). Thanks again for the assist. Let me know if I can help further!

@snipe
Copy link
Owner

snipe commented Jan 14, 2014

I think I see what's happening. It’s not looking in app/config/local for mail.php, only in app/config. Try cp'ing your mail.php into the app/config directory and try re-running.

@seanknox
Copy link
Author

That was the missing piece. I also had to copy app/config/local/database.php into app/config. After I did that, I was able to run composer install and php artisan app:install successfully.

Sounds like something isn't looking in app/config/$ENV like it should?

@snipe
Copy link
Owner

snipe commented Jan 14, 2014

Yep - that's what I'm trying to track down. It looks like it's correctly defaulting to local, but it's not looking in the right place for local config files.

@snipe
Copy link
Owner

snipe commented Jan 14, 2014

Okay, mystery solved. It's sort of a bug, but not exactly.

You're running these scripts as command line scripts, so the hostname you provide for apache doesn't actually matter here. What it's looking at is the hostname of your machine, since cli doesn't deal with apache.

My computer name, probably like yours, does not have "local" in the name, so the environmental variables for local wouldn't match, so Laravel was defaulting to production every time.

This problem can be solved by adding your machine's name (in your Mac terminal, type hostname) to the local hostname array, or by passing the environmental override in the setup, as:

php artisan app:install --env=local

Sorry for the hassle - I should really have caught that and specified it in the docs.

@snipe snipe closed this as completed Jan 14, 2014
@seanknox
Copy link
Author

👍 Thanks for tracking this down. Looking forward to playing with snipe-it some more.

snipe added a commit that referenced this issue Jan 14, 2014
@snipe
Copy link
Owner

snipe commented Jan 14, 2014

Updated the README in ea0560e to clarify this issue - thanks again - I'm sure we've just saved a lot of people some real headaches!

@rkayutkin rkayutkin mentioned this issue Jun 14, 2019
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants