Magento admin css missing due to using file system path - css

I was unable to install a module using Magento Connect, getting a Connection Error try again later error. Following the instructions of the module developer I attempted to fix permissions in the document root with:
find . -type f -exec chmod 644 {} \;
find . -type d -exec chmod 755 {} \;
chmod o+w var var/.htaccess app/etc
chmod 550 mage
chmod -R o+w media
It still didn't work so I ended up installing the module manually. I then logged into the admin backend and Magento was trying serve CSS files using the system file paths instead of URLs like so:
<link rel="stylesheet" type="text/css" href="/home/user/public_html/js/calendar/calendar-win2k-1.css" />
<link rel="stylesheet" type="text/css" href="/home/user/public_html/skin/adminhtml/default/default/reset.css" media="all" />
<link rel="stylesheet" type="text/css" href="/home/user/public_html/skin/adminhtml/default/default/boxes.css" media="all" />
<link rel="stylesheet" type="text/css" href="/home/user/public_html/skin/adminhtml/default/default/custom.css" media="all" />
<link rel="stylesheet" type="text/css" href="/home/user/public_html/skin/adminhtml/default/default/xmlconnect/boxes.css" media="all" />
<link rel="stylesheet" type="text/css" href="/home/user/public_html/skin/adminhtml/default/default/print.css" media="print" />
<link rel="stylesheet" type="text/css" href="/home/user/public_html/skin/adminhtml/default/default/menu.css" media="screen, projection" />
I immediately removed the extension and tried to match the perms from another server with a working Magento to no avail. I have also:
Cleared local, APC, and Magento caches
Looked in error logs (logging is enabled)
double-checked proper values of web/unsecure/base_url and web/secure/base_url in the DB
Rebooted, 3 times ;)
Minify is not being used. Merge CSS files are enabled, however I cannot figure out how to disable without the admin interface (save and navigation isn't working, even when I replace the correct values with Firebug). Any ideas would be greatly appreciated!

EDIT: As mentioned by #michael-hampton, this solution opens a serious security hole and shouldn't be used. Please don't use in production!
I ran into the same problem, and it happens that file permissions were not set properly.
In order to allow Magento to generate assets files, media directory must be writable by apache user.
So doing
chmod -R o+w media
will not necessarily allow apache to write in media directory, if apache don't own this directory.
You should check that apache actually own media directory, by checking first which user apache is running as, and then ajust permissions accordingly :
chown -R <apache_user> media
chmod -R o+w media
More information here: Magento Filesystem Permissions

A much simpler approach is to just head over to magento database and alter the table core_config_data manually. There should be an entry named dev/js/merge_files and dev/css/merge_files.
These two should hold values of 1.By setting these two values to 0, you'll get this fixed and your css and js files should be loadable again. tested in magento 1.5.x.

I ended up fixing it by being able to disable CSS merge by browsing to the relevant admin page and entering configForm.submit() in my java console to save the settings.
Not sure why CSS merge started using the file system paths of all a sudden, I wasn't changing anything associated with that (the module I was installing was for invoices). I've had a lot of randoms problem like this with Magento, it seems to require constant tinkering. I definitely am hesitant to recommend another client go with Magento again.

If you're using Fooman Speedster, just uninstall it from the Magento Connect Package Manager. Then, reinstall it.
Don't use the reinstall feature in the package manager, because it will not work.

Sometimes, you need to make sure that you have the media folder in your Magento root directory.

Related

CSS file not loading Laravel Localhost

I am trying to load CSS file in localhost but it's just showing white page. I was try to drag and drop file direct to browser and its opened. So file its not empty. and file also open when i use a server and add link to file.
I am using laravel 5.8, PHP 7.2
<link href="{{ URL::asset('css/style.css') }}" rel="stylesheet" type="text/css" media="all" />
CSS file location /public/css i am getting link in source http://localhost/css/style.css
This is most likely a file reference error. Check the markup output and compare the file URL against where it actually sits in the directory structure. If they match up, maybe a directory permissions issue?
In css links only asset is working fine... No need to include URL. so try using only asset.

Django, forcing reload of css/js, and collectstatic

Let's say that I've done a good bit of update to my css files on my dev machine (with my browser set to ignore the cache, no always seeing updates right away).
In this question and other places, I've seen the approach of adding a version number to the links:
<link type="text/css" href={% static "/path/mystyles.css?version=2" %} rel="stylesheet">,
which is fine, but on the dev machine, I get an error in the console, and the file isn't found:
GET http://127.0.0.1:8000/path/mystyles.css%3Fversion%3D2 net::ERR_ABORTED 404 (Not Found)
I've read that perhaps collectstatic will fix it on the dev side, but there's an ominous-looking warning:
You have requested to collect static files at the destination
location as specified in your settings:
/patttthhhhh/static
This will overwrite existing files!
Are you sure you want to do this?
What will happen when I run collectstatic? Where will it get files from to overwrite those?
The recommended way would be to use something like django-compressor (usage) or the likes to process your CSS into a single file and then bake a hash into the filename or dir. So that way your asset would become /mystyles.beb23fe.css.
What ended up working easily was changing the format of the version tag:
<link type="text/css" href="{% static '/path/mystyle.css' %}?version=2" rel="stylesheet">
instead of:
<link type="text/css" href={% static "/path/mystyles.css?version=2" %} rel="stylesheet">
Is fine in dev and production.

Symfony - Assets in dev mode

I am working through symfony tutorials and the documentation, it seems to imply that in dev mode the resources are available without having to install the assets, something like:
<link rel="stylesheet" href="{{ asset("bundles/yodauser/css/login.css") }}" />
I get a 404 error though in dev mode until I actually run the assets:install command.
What am I doing wrong?
Quoting documentation:
http://symfony.com/doc/current/book/templating.html#including-stylesheets-and-javascripts-in-twig
You can also include assets located in your bundles' Resources/public
folder. You will need to run the php bin/console assets:install target
[--symlink] command, which moves (or symlinks) files into the correct
location. (target is by default "web").
<link href="{{ asset('bundles/acmedemo/css/contact.css') }}" rel="stylesheet" />
It should work, in my case sometimes it does sometimes it doeasnt.
Worst case scenario you will have to run command every time you update assets.
404 Error will be trough when the file don't exist on your server!(not found...) (W3 official doc here). The file don't exist in your target folder (or you target the wrong file ^^) ...
have you think to load your ressources in your web/ folder with this command:
# make a hard copy of the assets in web/
$ php app/console assets:install
# if possible, make absolute symlinks in web/ if not, make a hard copy
$ php app/console assets:install --symlink
# if possible, make relative symlinks in web/ if not, make a hard copy
$ php app/console assets:install --symlink --relative
This a new command on SF2.6 and you can find more samples of this command documentation here
you have all the documentation of assetics on the officoal symfony website.
And few idea for the best practise here.
Also, it's better to use the ' character in your asset() function like that :
<link rel="stylesheet" href="{{ asset('bundles/yodauser/css/login.css') }}" />

Symfony2:css, images and assetic

I've put a css file in MyDirectoryBundle/Resources/public/css.
I then linked to it using:
<link href="{{ asset('css/main.css') }}" type="text/css" rel="stylesheet" />
I checked if it worked
short test: body {color: #FF0000;}
Nothing changed.
The parent layout (layout.twig.html) is in app/Resources/views (3 level architecture).
I still don't understand why:
css does not work
why the command: php console assets:install web/ --symlink fails
-> answer: The target directory web does not exist. (it does exist, actually).
I am quite new to symfony2 (2 weeks practice only).
I am working on Windows - just in case this may explain something...
Thank you very much for your help!
If the file first lived in MyDirectoryBundle/Resources/public/css, it'll be copied to web/bundles/mydirectory/css. So you have to include it like: {{ asset('bundles/mydirectory/css/main.css') }}.
You should execute the command from the root of your project. As you're using php console, it seems like you're in the app/ directory when executing this command. In that case, app/web/ does not exists, so the error is completely valid.
As you're on Windows, there is a change that symlink is not allowed/available. I believe it's available for admins only since Windows vista.
As a side tip, if MyDirectoryBundle is your app bundle (a bundle tied to your app and not meant to be reused by other apps), I would recommend to put the CSS file in the web/ directory directly. There is no need to put it in the bundle in such a case (this is only related to bundles that are shared, so the CSS is shared as well).
use php app/console instead of php console

Access to restricted URI denied when linking to LESS css

I just downloaded the semantic CSS and was running the examples but saw the following error on Firefox
Access to restricted URI denied
file:///C:/semanticcss/examples/fixed/fixed.less
Below is the code in the example page
<!-- Stylesheets -->
<link rel="stylesheet" href="fixed.less" type="text/less" media="screen" />
<!-- Scripts -->
<script src="../../js/less-1.1.3.min.js" type="text/javascript"></script>
How can I get rid of this error?
This is on purpose. Local files may only read other local files in the same directory or sub-directories.
See https://developer.mozilla.org/en/Same-origin_policy_for_file%3a_URIs
Try
[sudo] npm install less -g
Then it shouldn't have any problems with the directories. My system (MBP) did the same thing until I did this. The main problem was that it doesn't know where the LESS compiler is located. You will more than likely need root privileges to run the command, hence [sudo] is system dependent.
Hope this helps.

Resources