snipe / snipe-it

A free open source IT asset/license management system
https://snipeitapp.com
GNU Affero General Public License v3.0
10.84k stars 3.14k forks source link

Import of Assets #2715

Closed webberm closed 7 years ago

webberm commented 7 years ago

Expected Behavior (or desired behavior if a feature request)

I click process for CSV file and it imports


Actual Behavior

Whoops, looks like something went wrong.


Please confirm you have done the following before posting your bug report:


Please provide answers to these questions before posting your bug report:

PHP Fatal error: Uncaught UnexpectedValueException: The stream or file "/var/www/snipeit/storage/logs/importer.log" could not be opened: failed to open stream: Permission denied in /var/www/snipeit/bootstrap/cache/compiled.php:13906 Stack trace:

0 /var/www/snipeit/bootstrap/cache/compiled.php(13836): Monolog\Handler\StreamHandler->write(Array)

1 /var/www/snipeit/bootstrap/cache/compiled.php(13596): Monolog\Handler\AbstractProcessingHandler->handle(Array)

2 /var/www/snipeit/bootstrap/cache/compiled.php(13694): Monolog\Logger->addRecord(400, Object(UnexpectedValueException), Array)

3 /var/www/snipeit/bootstrap/cache/compiled.php(13389): Monolog\Logger->error(Object(UnexpectedValueException), Array)

4 /var/www/snipeit/bootstrap/cache/compiled.php(13360): Illuminate\Log\Writer->writeLog('error', Object(UnexpectedValueException), Array)

5 /var/www/snipeit/vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php(57): Illuminate\Log\Writer->error(Object(UnexpectedValueException))

6 /var/www/snipeit/app/Except in /var/www/snipeit/bootstrap/cache/compiled.php on line 13906

PHP Fatal error: Uncaught UnexpectedValueException: The stream or file "/var/www/snipeit/storage/logs/importer.log" could not be opened: failed to open stream: Permission denied in /var/www/snipeit/bootstrap/cache/compiled.php:13906 Stack trace:

0 /var/www/snipeit/bootstrap/cache/compiled.php(13836): Monolog\Handler\StreamHandler->write(Array)

1 /var/www/snipeit/bootstrap/cache/compiled.php(13596): Monolog\Handler\AbstractProcessingHandler->handle(Array)

2 /var/www/snipeit/bootstrap/cache/compiled.php(13694): Monolog\Logger->addRecord(400, Object(Symfony\Component\Debug\Exception\FatalErrorException), Array)

3 /var/www/snipeit/bootstrap/cache/compiled.php(13389): Monolog\Logger->error(Object(Symfony\Component\Debug\Exception\FatalErrorException), Array)

4 /var/www/snipeit/bootstrap/cache/compiled.php(13360): Illuminate\Log\Writer->writeLog('error', Object(Symfony\Component\Debug\Exception\FatalErrorException), Array)

5 /var/www/snipeit/vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php(57): Illumi in /var/www/snipeit/bootstrap/cache/compiled.php on line 13906

webberm commented 7 years ago

Here is the error after enabling debug mode:

FatalThrowableError in Encoding.php line 339: Call to undefined function ForceUTF8\utf8_decode() in Encoding.php line 339 at Encoding::utf8_decode('Laptop', '') in Encoding.php line 280 at Encoding::fixUTF8('Laptop') in ObjectImportCommand.php line 288 at ObjectImportCommand->array_smart_fetch(array('name' => '', 'email' => '', 'username' => '', 'item name' => '', 'category' => 'Laptop', 'model name' => 'ThinkPad T440P', 'manufacturer' => 'Lenovo', 'model number' => '20AWS2YF00', 'serial number' => 'PC03GN9H', 'asset tag' => '25168', 'location' => '', 'notes' => '', 'purchase date' => '', 'purchase cost' => '', 'company' => '', 'status' => '', 'warranty months' => '', 'supplier' => ''), 'category') in ObjectImportCommand.php line 138 at ObjectImportCommand->App\Console\Commands{closure}(object(MySqlConnection)) in Connection.php line 543 at Connection->transaction(object(Closure)) at call_user_func_array(array(object(MySqlConnection), 'transaction'), array(object(Closure))) in compiled.php line 11804 at DatabaseManager->call('transaction', array(object(Closure))) in compiled.php line 6325 at Facade::callStatic('transaction', array(object(Closure))) in ObjectImportCommand.php line 209 at ObjectImportCommand->fire() at call_user_func_array(array(object(ObjectImportCommand), 'fire'), array()) in compiled.php line 1257 at Container->call(array(object(ObjectImportCommand), 'fire')) in Command.php line 169 at Command->execute(object(ArrayInput), object(BufferedOutput)) in Command.php line 256 at Command->run(object(ArrayInput), object(BufferedOutput)) in Command.php line 155 at Command->run(object(ArrayInput), object(BufferedOutput)) in Application.php line 794 at Application->doRunCommand(object(ObjectImportCommand), object(ArrayInput), object(BufferedOutput)) in Application.php line 186 at Application->doRun(object(ArrayInput), object(BufferedOutput)) in Application.php line 117 at Application->run(object(ArrayInput), object(BufferedOutput)) in Application.php line 64 at Application->call('snipeit:import', object(Collection)) in Kernel.php line 170 at Kernel->call('snipeit:import', array('filename' => '/var/www/snipeit/storage/private_uploads/imports/assets/2016-09-29-015221-Snipe_Import-tes.csv', '--email_format' => 'firstname.lastname', '--username_format' => 'firstname.lastname', '--web-importer' => true, '--user_id' => '1390', '--item-type' => 'asset')) in compiled.php line 6327 at Facade::__callStatic('call', array('snipeit:import', array('filename' => '/var/www/snipeit/storage/private_uploads/imports/assets/2016-09-29-015221-Snipe_Import-tes.csv', '--email_format' => 'firstname.lastname', '--username_format' => 'firstname.lastname', '--web-importer' => true, '--user_id' => '1390', '--item-type' => 'asset'))) in AssetsController.php line 972 at AssetsController->postProcessImportFile() at call_user_func_array(array(object(AssetsController), 'postProcessImportFile'), array()) in compiled.php line 9424 at Controller->callAction('postProcessImportFile', array()) in compiled.php line 9486 at ControllerDispatcher->call(object(AssetsController), object(Route), 'postProcessImportFile') in compiled.php line 9466 at ControllerDispatcher->Illuminate\Routing{closure}(object(Request)) at call_user_func(object(Closure), object(Request)) in Pipeline.php line 52 at Pipeline->Illuminate\Routing{closure}(object(Request)) in Authenticate.php line 45 at Authenticate->handle(object(Request), object(Closure)) at call_user_func_array(array(object(Authenticate), 'handle'), array(object(Request), object(Closure))) in compiled.php line 9963 at Pipeline->Illuminate\Pipeline{closure}(object(Request)) at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32 at Pipeline->Illuminate\Routing{closure}(object(Request)) at call_user_func(object(Closure), object(Request)) in compiled.php line 9948 at Pipeline->then(object(Closure)) in compiled.php line 9467 at ControllerDispatcher->callWithinStack(object(AssetsController), object(Route), object(Request), 'postProcessImportFile') in compiled.php line 9454 at ControllerDispatcher->dispatch(object(Route), object(Request), 'App\Http\Controllers\AssetsController', 'postProcessImportFile') in compiled.php line 8524 at Route->runController(object(Request)) in compiled.php line 8511 at Route->run(object(Request)) in compiled.php line 8225 at Router->Illuminate\Routing{closure}(object(Request)) at call_user_func(object(Closure), object(Request)) in Pipeline.php line 52 at Pipeline->Illuminate\Routing{closure}(object(Request)) in CheckPermissions.php line 27 at CheckPermissions->handle(object(Request), object(Closure), 'assets.create') at call_user_func_array(array(object(CheckPermissions), 'handle'), array(object(Request), object(Closure), 'assets.create')) in compiled.php line 9963 at Pipeline->Illuminate\Pipeline{closure}(object(Request)) at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32 at Pipeline->Illuminate\Routing{closure}(object(Request)) in Authenticate.php line 45 at Authenticate->handle(object(Request), object(Closure)) at call_user_func_array(array(object(Authenticate), 'handle'), array(object(Request), object(Closure))) in compiled.php line 9963 at Pipeline->Illuminate\Pipeline{closure}(object(Request)) at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32 at Pipeline->Illuminate\Routing{closure}(object(Request)) in CheckLocale.php line 40 at CheckLocale->handle(object(Request), object(Closure)) at call_user_func_array(array(object(CheckLocale), 'handle'), array(object(Request), object(Closure))) in compiled.php line 9963 at Pipeline->Illuminate\Pipeline{closure}(object(Request)) at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32 at Pipeline->Illuminate\Routing{closure}(object(Request)) in compiled.php line 3225 at VerifyCsrfToken->handle(object(Request), object(Closure)) at call_user_func_array(array(object(VerifyCsrfToken), 'handle'), array(object(Request), object(Closure))) in compiled.php line 9963 at Pipeline->Illuminate\Pipeline{closure}(object(Request)) at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32 at Pipeline->Illuminate\Routing{closure}(object(Request)) in compiled.php line 13213 at AddQueuedCookiesToResponse->handle(object(Request), object(Closure)) at call_user_func_array(array(object(AddQueuedCookiesToResponse), 'handle'), array(object(Request), object(Closure))) in compiled.php line 9963 at Pipeline->Illuminate\Pipeline{closure}(object(Request)) at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32 at Pipeline->Illuminate\Routing{closure}(object(Request)) in compiled.php line 13150 at EncryptCookies->handle(object(Request), object(Closure)) at call_user_func_array(array(object(EncryptCookies), 'handle'), array(object(Request), object(Closure))) in compiled.php line 9963 at Pipeline->Illuminate\Pipeline{closure}(object(Request)) at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32 at Pipeline->Illuminate\Routing{closure}(object(Request)) at call_user_func(object(Closure), object(Request)) in compiled.php line 9948 at Pipeline->then(object(Closure)) in compiled.php line 8226 at Router->runRouteWithinStack(object(Route), object(Request)) in compiled.php line 8217 at Router->dispatchToRoute(object(Request)) in compiled.php line 8207 at Router->dispatch(object(Request)) in compiled.php line 2419 at Kernel->Illuminate\Foundation\Http{closure}(object(Request)) at call_user_func(object(Closure), object(Request)) in Pipeline.php line 52 at Pipeline->Illuminate\Routing{closure}(object(Request)) in Debugbar.php line 49 at Debugbar->handle(object(Request), object(Closure)) at call_user_func_array(array(object(Debugbar), 'handle'), array(object(Request), object(Closure))) in compiled.php line 9963 at Pipeline->Illuminate\Pipeline{closure}(object(Request)) at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32 at Pipeline->Illuminate\Routing{closure}(object(Request)) in TrustProxies.php line 46 at TrustProxies->handle(object(Request), object(Closure)) at call_user_func_array(array(object(TrustProxies), 'handle'), array(object(Request), object(Closure))) in compiled.php line 9963 at Pipeline->Illuminate\Pipeline{closure}(object(Request)) at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32 at Pipeline->Illuminate\Routing{closure}(object(Request)) in CheckForSetup.php line 22 at CheckForSetup->handle(object(Request), object(Closure)) at call_user_func_array(array(object(CheckForSetup), 'handle'), array(object(Request), object(Closure))) in compiled.php line 9963 at Pipeline->Illuminate\Pipeline{closure}(object(Request)) at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32 at Pipeline->Illuminate\Routing{closure}(object(Request)) in NosniffGuard.php line 17 at NosniffGuard->handle(object(Request), object(Closure)) at call_user_func_array(array(object(NosniffGuard), 'handle'), array(object(Request), object(Closure))) in compiled.php line 9963 at Pipeline->Illuminate\Pipeline{closure}(object(Request)) at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32 at Pipeline->Illuminate\Routing{closure}(object(Request)) in XssProtectHeader.php line 17 at XssProtectHeader->handle(object(Request), object(Closure)) at call_user_func_array(array(object(XssProtectHeader), 'handle'), array(object(Request), object(Closure))) in compiled.php line 9963 at Pipeline->Illuminate\Pipeline{closure}(object(Request)) at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32 at Pipeline->Illuminate\Routing{closure}(object(Request)) in FrameGuard.php line 17 at FrameGuard->handle(object(Request), object(Closure)) at call_user_func_array(array(object(FrameGuard), 'handle'), array(object(Request), object(Closure))) in compiled.php line 9963 at Pipeline->Illuminate\Pipeline{closure}(object(Request)) at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32 at Pipeline->Illuminate\Routing{closure}(object(Request)) in compiled.php line 13474 at ShareErrorsFromSession->handle(object(Request), object(Closure)) at call_user_func_array(array(object(ShareErrorsFromSession), 'handle'), array(object(Request), object(Closure))) in compiled.php line 9963 at Pipeline->Illuminate\Pipeline{closure}(object(Request)) at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32 at Pipeline->Illuminate\Routing{closure}(object(Request)) in compiled.php line 11964 at StartSession->handle(object(Request), object(Closure)) at call_user_func_array(array(object(StartSession), 'handle'), array(object(Request), object(Closure))) in compiled.php line 9963 at Pipeline->Illuminate\Pipeline{closure}(object(Request)) at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32 at Pipeline->Illuminate\Routing{closure}(object(Request)) in CheckForMaintenanceMode.php line 145 at CheckForMaintenanceMode->handle(object(Request), object(Closure)) at call_user_func_array(array(object(CheckForMaintenanceMode), 'handle'), array(object(Request), object(Closure))) in compiled.php line 9963 at Pipeline->Illuminate\Pipeline{closure}(object(Request)) at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32 at Pipeline->Illuminate\Routing{closure}(object(Request)) at call_user_func(object(Closure), object(Request)) in compiled.php line 9948 at Pipeline->then(object(Closure)) in compiled.php line 2366 at Kernel->sendRequestThroughRouter(object(Request)) in compiled.php line 2350 at Kernel->handle(object(Request)) in index.php line 59

snipe commented 7 years ago

Run composer install again, and check that your storage directory and sub-dirs are writable

webberm commented 7 years ago

I ran php composer.phar install and it says,

Problem 1

I then tried to run:

php composer.phar update

[RuntimeException] /var/www/snipeit/vendor/codeception/c3 does not exist and could not be created.

I was told the whole system was installed using the install.sh script.

webberm commented 7 years ago

Is it possible to know what permissions are supposed to set to and I can add them manually to test?

snipe commented 7 years ago

Sorry, you want to run composer install with the --no-dev flag, otherwise it's going to need more libraries

webberm commented 7 years ago

php composer.phar install --no-dev

[ErrorException] file_put_contents(/var/www/snipeit/vendor/composer/installed.json): failed to open stream: Permission denied

I also tried php composer.phar install --no-dev --prefer-source

Same error

webberm commented 7 years ago

I tried php composer.phar update --no-dev

This is the output

DidntHaveToUseMyAK commented 7 years ago

We are experiencing the same results when trying to import the same way. Ubuntu 16.04 with stock LAMP install and Snipe version v3.4-14-g2a8ab06. Have not tried running composer but will try now. We used sample CSV file to test known good data - this also resulted in the same error that @webberm was receiving.

webberm commented 7 years ago

I rebooted and it worked. Grrr.

DidntHaveToUseMyAK commented 7 years ago

Which worked? Composer or the import?

webberm commented 7 years ago

the import

DidntHaveToUseMyAK commented 7 years ago

Tried the reboot trick... nada. I'll attempt the composer deal.

webberm commented 7 years ago

Good Luck.

DidntHaveToUseMyAK commented 7 years ago

I like how it tells you not to run Composer as root/super user while it's in the process of doing just that...

DidntHaveToUseMyAK commented 7 years ago

Ran it without being SU and this is what I received. $ php composer.phar update --no-dev

php artisan clear-compiled PHP Fatal error: Uncaught UnexpectedValueException: The stream or file "/var/www/snipeit/storage/logs/laravel.log" could not be opened: failed to open stream: Permission denied in /var/www/snipeit/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php:107 Stack trace:

0 /var/www/snipeit/vendor/monolog/monolog/src/Monolog/Handler/AbstractProcessingHandler.php(37): Monolog\Handler\StreamHandler->write(Array)

1 /var/www/snipeit/vendor/monolog/monolog/src/Monolog/Logger.php(336): Monolog\Handler\AbstractProcessingHandler->handle(Array)

2 /var/www/snipeit/vendor/monolog/monolog/src/Monolog/Logger.php(615): Monolog\Logger->addRecord(400, Object(UnexpectedValueException), Array)

3 /var/www/snipeit/vendor/laravel/framework/src/Illuminate/Log/Writer.php(202): Monolog\Logger->error(Object(UnexpectedValueException), Array)

4 /var/www/snipeit/vendor/laravel/framework/src/Illuminate/Log/Writer.php(113): Illuminate\Log\Writer->writeLog('error', Object(UnexpectedValueException), Array)

5 /var/www/snipeit/vendor/laravel/framework in /var/www/snipeit/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php on line 107

PHP Fatal error: Uncaught UnexpectedValueException: The stream or file "/var/www/snipeit/storage/logs/laravel.log" could not be opened: failed to open stream: Permission denied in /var/www/snipeit/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php:107 Stack trace:

0 /var/www/snipeit/vendor/monolog/monolog/src/Monolog/Handler/AbstractProcessingHandler.php(37): Monolog\Handler\StreamHandler->write(Array)

1 /var/www/snipeit/vendor/monolog/monolog/src/Monolog/Logger.php(336): Monolog\Handler\AbstractProcessingHandler->handle(Array)

2 /var/www/snipeit/vendor/monolog/monolog/src/Monolog/Logger.php(615): Monolog\Logger->addRecord(400, Object(Symfony\Component\Debug\Exception\FatalErrorException), Array)

3 /var/www/snipeit/vendor/laravel/framework/src/Illuminate/Log/Writer.php(202): Monolog\Logger->error(Object(Symfony\Component\Debug\Exception\FatalErrorException), Array)

4 /var/www/snipeit/vendor/laravel/framework/src/Illuminate/Log/Writer.php(113): Illuminate\Log\Writer->writeLog('error', Object(Symfony\Component\De in /var/www/snipeit/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php on line 107

Script php artisan clear-compiled handling the pre-update-cmd event returned with error code 255

DidntHaveToUseMyAK commented 7 years ago

Ran composer again as SU instead of trying to figure out all the perms (I'm a rebel... I know), rebooted (windows habit), and then attempted import again... SUCESS!